0

I have Ubuntu 13.04 32-bit installed on my system.

I downloaded Java SE Development Kit 7 from here with the extention .tar.gz

I used the command tar xvfz Downloads/jdk-7u51-linux-i586.tar.gz to uncompress the downloaded file in my home directory i.e /home/computer/

I am able to compile and run java program using Bluej IDE. It is working fine. I used the command jdk1.7.0_51/bin/java -jar Downloads/bluej-310.jar to install bluej IDE.

But I also want to compile and run java programs using the terminal in Ubuntu.

When I type the command java -version I get the message

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.6-jre-headless
 * gcj-4.7-jre-headless
 * openjdk-7-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>

Can anyone please help me out.

rainu
  • 733
  • 2
  • 12
  • 26
  • `sudo apt-get install openjdk-7-jre-headless`? – devnull Mar 15 '14 at 06:53
  • this question is more appropriately placed in askubuntu.com – Mestica Mar 15 '14 at 07:09
  • I added the path "export PATH=$PATH:/home/computer/jdk1.7.0_51/bin" at the end in .profile file accessed from hidden files in home directory using "Ctrl+H" and it worked after logging off. I don't have to do this step every time I restart the system. – rainu Mar 22 '14 at 03:42

3 Answers3

0

You can either install openjdk-7-jdk or add the bin directory of your downloaded distribution to your PATH variable and make it permanent by doing it in the configuration file of your shell. (Most likely .bash_profile in your home directory).

The easiest is probably sudo apt-get install openjdk-7-jdk (and then you can delete the one you downloaded).

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • I was following the instructions given in this [link](http://horstmann.com/sjsu/cs46a/bluej-linux/) to install bluej. If I delete the present installation Bluej won't work. I will try to add the bin directory to my PATH variable. thank you for the reply. – rainu Mar 15 '14 at 09:43
0

I suggest that follow the instructions on https://help.ubuntu.com/community/Java. I think it's a lot more easier if you focused on the section regarding openjdk than sections on oracle java 7 than IBM 4. You may use the ubuntu software center app to locate the packages and install them rather than using the terminal.

Mestica
  • 1,489
  • 4
  • 23
  • 33
0

You haven't completely installed java.. You are attempting to run the bash command

$java

and wherever you have extracted the jre, it isn't in your $PATH...

You must add it to your path like so:

$export PATH=$PATH:/home/computer/%THE_JAVA_DIR_THAT_YOU_INSTALLED%

or better yet, get rid of the stuff you extracted and do this:

$sudo apt-get install openjdk-6-jre

It can save you a bit of a hassle to use Ubuntu's apt-get to install programs whenever possible

================EDIT

if ~/.profile doesn't exist, create it

Add the following lines in your .profile file in your home directory (using vi ~/.profile):

PATH=$PATH:/home/me/play
export PATH

Then, for the change to take effect, simply type in your terminal:

$ . ~/.profile

Shane
  • 315
  • 1
  • 5
  • 12
  • I was following the instructions given on [link](http://horstmann.com/sjsu/cs46a/bluej-linux/) to install Bluej. Bluej is working fine, it compiles and runs .java files, but I need to compile and run using terminal. I will try to add the path and see if it works. Thank you for the reply. – rainu Mar 15 '14 at 09:37
  • I added the bin directory to my PATH using the commands export PATH=$PATH:/home/computer/jdk1.7.0_51/bin source .bashrc This worked but had to do it every time the terminal restarts. – rainu Mar 15 '14 at 11:35