Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got java installed on my Ubuntu VirtualBox, and I am trying to run sunspot, but sunspot can't find java.

typing 'java' from the command line return

The program 'java' can be found in the following packages:
 * gcj-4.4-jre-headless
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
 * gcj-4.5-jre-headless
 * openjdk-7-jre-headless

and everything I've seen says that java should be in '/usr/lib/jdk', but I don't have '/usr/lib/jdk' in my directory.

How can I:

  1. Find the install for openjdk-7-jre-headless
  2. sudo export home, as I've had problems in the past setting the export home, without proper access
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I'm not sure what you mean exactly by your questions, but...

Find the install for openjdk-7-jre-headless

You can do this by using apt-get at the command line:

apt-get install openjdk-7-jre-headless

Follow the prompts and it'll install this package and everything it needs.

sudo export home, as I've had problems in the past setting the export home, without proper access

If you execute the command sudo export home, it does nothing - and wouldn't work. export is a shell internal command, and sudo requires a binary. Even if you made that command work through shell trickery, you'd just set the variable (which should be JAVA_HOME) in a new shell then forgets it when the command is done.

You might need to run java as root, but I wouldn't do that either: fix the permissions on the files and executables, and don't run as root as this will open your system up to hackers and miscreants.

share|improve this answer
    
I've already installed jdk (or atleast I think i did, I tried to), and when I type java into the command line, I thought it would say not found if I didn't have it installed. –  Pete Field Jan 10 '12 at 15:54
    
you were right david, apparently jdk wasn't installed (or atleast I've done it again. –  Pete Field Jan 10 '12 at 16:05
    
What you were seeing (instead of just command not found) is part of an Ubuntu package called (appropriately) command-not-found. It's not necessary; the added delay while it searches the database drives me up a wall. I usually remove it: apt-get remove command-not-found command-not-found-data. –  David Jan 10 '12 at 16:56
add comment

You can make sure you have a java package installed using:

$ sudo dpkg -l | grep jre
$ sudo dpkg -l | grep jdk

From the error you got after typing java, I think java is not installed.

Also, you can use which java to search for the binary java in your path. To export the java, you can for example use:

$ export JAVA_HOME=/path/to/your/java/home
share|improve this answer
    
Thanks Khaled, the sudo dpgk and which java commands don't return anything, so I'm not sure what that means. It didn't return the path to my java. If java was not installed, I thought I would get a 'not found' error when typing java at the command line. –  Pete Field Jan 10 '12 at 15:52
    
It seems that you don't have java installed. You can try to install it using apt-get install. –  Khaled Jan 10 '12 at 16:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.