It depends where you develop your program. If you use and kind of IDE Java can usually be changed in the project settings.
If you compile your program via command line (meaning javac
etc.) you can change the desired Java environment by adding the following llines to your ~/.bashr_profile
(which is run every time you open a terminal. You didn't tell which shell you use so I assume it is bash. You also did not state which distribution you run. Arch Linux for example offers a nice and easy script to change the Java environment, archlinux-java
. The general case:
Add the following lines to the ~.bash_profile
:
export JAVA_HOME=path/to/java
export PATH=$PATH:/path/to/java/bin
Save, quit, logout and login again and you should be good to go.
Most Linux distributions offer mechanisms for managing multiple Java versions. You’ll have to be more specific. – Daniel B – 2014-12-17T07:02:51.637
I am having jre 1.6.0.35 in my linux mahcine. Now i am working on SCTP support in jre7 (not supported in jre6 and not supported on windows), so I want to test a simple java program which requires the SCTP library of jre7 and a linux machine. – vaibhav – 2014-12-17T07:12:45.327
The keyword was “distribution”, as in which. – Daniel B – 2014-12-17T07:49:46.537