How to get/set Java version, JAVA_HOME and Classpath
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
How to get/set Java version, JAVA_HOME and Classpath
I need step-by-step instructions on how to
1. check JAVA version,
2. set up the JAVA_HOME and
3. CLASSPATH variables
I had installed
1. NetbeansIDE 6.7.1 from Software Center
2. MySQL from command sudo apt-get install mysql-server
3. libmysql-java from synaptic package manager
OS Information
1. Partition 1, 3.0 GB Swap Space, /dev/sda1
2. Partition 2, 6.0 GB Filesystem, /dev/sda2 mount at /, Bootable
3. Partition 3, Ext4, /dev/sda3 mount at /home
4. Partition 4, /dev/sda4, Extended (Drive A, Drive B and Drive C)
1. check JAVA version,
2. set up the JAVA_HOME and
3. CLASSPATH variables
I had installed
1. NetbeansIDE 6.7.1 from Software Center
2. MySQL from command sudo apt-get install mysql-server
3. libmysql-java from synaptic package manager
OS Information
1. Partition 1, 3.0 GB Swap Space, /dev/sda1
2. Partition 2, 6.0 GB Filesystem, /dev/sda2 mount at /, Bootable
3. Partition 3, Ext4, /dev/sda3 mount at /home
4. Partition 4, /dev/sda4, Extended (Drive A, Drive B and Drive C)
I found the following to be helpful when setting up java on Fedora Core 12:
The following command will print the version of java you are currently using.
> java -version
The following command will print the home directory for the java executables for the version of java you are running. I assume that this is what you will want to correspond to JAVA_HOME. I'm not a developer so I am not 100% sure on this. This is typically /usr/bin/java.
> which java
I think it might be best practice to create a sym link between your current version and the more generic path. For example:
>ln -s /usr/java/jre1.x.x.x /usr/java/jre
This saved me a bit of aggravation when I upgraded java. The only item I had to change was the first sym link. My PATH variable etc. is preserved.
The following sym link should also be in place to direct you to the correct executables:
>ln -s /usr/java/jre/bin/java /usr/bin/java
In the event that "/usr/bin" is *not* in the PATH variable (unlikely), the following command may be used to add it.
>PATH=/usr/bin:$PATH then export PATH
My understanding is that this will only stay put for the duration of the session. Editing the PATH variable as it exists in /etc/profile is a more permanent method.
I'm not sure how to set the class path, but I hope the above helps.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.