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 went to SUN's website and downloaded the .bin:

https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS%5FDeveloper-Site/en%5FUS/-/USD/ViewFilteredProducts-SingleVariationTypeFilter

I ran it, checked the terms, and this is shown:

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Sun products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the Sun Product Registration form for
the JDK will be presented. If you do not register, none of
this information will be saved. You may also register your
JDK later by opening the register.html file (located in
the JDK installation directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....
Done.

However, when I type "java" in my terminal, it says: -bash: java: command not found

How do I check if it was successfully installed? Isn't that how you check?

share|improve this question
add comment

5 Answers

up vote 4 down vote accepted

If you're running a debian-based installation, I highly recommend you get the JDK from the repositories. You can simply run the following in a terminal:

$ sudo aptitude install sun-java6-jdk

I'm not sure whether other distributions also carry Sun's JDK. You may find openjdk-6-jdk to be an equivalent FOSS alternative.

If you do not have a package manager or are trying to manually install the JDK, I assume you already got the correct version of the JDK From the Sun website. You can find their Java SE downloads page here: http://java.sun.com/javase/downloads/index.jsp

If you've done all this, then running "java" at the terminal should just work. If this doesn't, it could mean it wasn't installed correctly, or that it was simply installed into a location that isn't on your path.

Do you know where you chose to install it?

If you're sure it was installed, but are unsure where it might have installed, you could try running updatedb and then using locate to find the java runtime:

$ sudo updatedb
$ locate java

This should give you an idea of the directory that you may need to add to the PATH environment variable.

Of course, if locate returns no results, then the JDK likely was not installed.

share|improve this answer
add comment

What you did is the best way to install Java because the entire JDK is contained in one location. So, you downloaded say, jdk1.50_21.bin. I want to install it in /usr/local/, for instance.

  • prolly need to be root to do that but substitute your location for what i have below:

    1. cp jdk1.50_21.bin /usr/local

    2. cd /usr/local

    3. sh jdk1.50_21.bin

      • it will ask you to accept the license yada yada yada.... and you are done. you can check by:
    4. ls -l /usr/local/jdk1.5.0_21/ ... ... ..

      • now you need to edit the path and classpath. I have two choices, I can set system-wide PATH for everyone, or I can let individual users set their own paths. I will use individual first, my user is named joe:

      • logged in as joe

      • edit .bashrc and add the following at the end

export JAVA_HOME=/usr/local/jdk1.5.0_21
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
  • saved and exit .bashrc file. Log out and log back in as joe and test:
% which java
/usr/local/jdk1.5.0_21/bin/java
% echo $JAVA_HOME
/usr/local/jdk1.5.0_21
% echo $CLASSPATH
/usr/local/jdk ..................
% java -version
1.5.0_21

All the above command should yield output. You are good to go.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

If you want system-wide changes, you can put:

export JAVA_HOME=/usr/local/jdk1.5.0_21
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar

in /etc/profile file at the bottom. However, I suggest you keep it to local user, like joe above, and play around with it first.

share|improve this answer
    
+1 very helpful. I was able to run java command but running javac was saying command not found. I had recently installed jdk (was previously having jre only). I was just missing the .bashrc edit part. It works perfect now. Thanks a lot –  Sandeepan Nath Jan 19 '11 at 6:52
add comment

Type in the terminal the following command $java -version

The out put should be The version you are using. for example i have this:

java version "1.6.0_23" OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2) OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)

share|improve this answer
add comment

I second mirzmaster's recommendation to use distro packages if possible.

Otherwise, Sun's Java usually installs somewhere into /opt/java* or /usr/lib/java* or sometimes /usr/java*. You'll find individual install directories there, such as /usr/java/jdk1.5.8. This is the directory that is your JAVA_HOME. Underneath it is /bin, where the binaries reside. Just run the javathere to check, e.g.

/usr/lib/java/jdk1.6.1/bin/java -version

That should get you started. Most IDEs will also ask for this directory to use the JDK/JRE.

To install the browser plugin, find the plugin which will be somewhere under jree/plugin and just copy/symlink it into your browser's plugins folder. In firefox, about:plugins should then list Java.

share|improve this answer
add comment

Once you have got the packages installed (and I agree with other posters regarding their preference for official distro-specific packagings), pointing your browser at Sun's Java tester page should give you confirmation the browser plugin and therefore Java applets are working.

share|improve this answer
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.