Running multiple Java versions on single Linux machine

0

My Linux machine with JRE 6 (1.6.0.35) is running a Java application. I am working on SCTP support in JRE 7 (not supported in JRE 6 and not supported on Windows), so I want to test a simple Java program which requires the SCTP library of JRE 7 and a Linux machine.

How can I use the same machine to test my simple Java program on JRE 7?

vaibhav

Posted 2014-12-17T06:58:12.523

Reputation: 13

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

Answers

0

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.

ap0

Posted 2014-12-17T06:58:12.523

Reputation: 1 180