My Linux machine with JRE 6 ( 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?

  • Most Linux distributions offer mechanisms for managing multiple Java versions. You’ll have to be more specific.
    – Daniel B
    Dec 17 '14 at 7:02
  • I am having jre 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
    Dec 17 '14 at 7:12
  • The keyword was “distribution”, as in which.
    – Daniel B
    Dec 17 '14 at 7:49

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.