File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes installing multiple versions of java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "installing multiple versions of java" Watch "installing multiple versions of java" New topic

installing multiple versions of java

srini manassu

Joined: Jan 07, 2012
Posts: 11

Hello Ranchers,

I want to know how to install java i.e. in order to run java programs what are all the necesssary packages required...
in the same context I would want to install java on windows(XP) as well as on linux (ubuntu) systems,
and also can I be able to install different versions of java 5, 6, 7 on the same OS?

PS: kindly provide a link to get the java package (required to install) (5, 6, 7) versions.

Thank you.
Deepak Rao
Ranch Hand

Joined: Jan 24, 2012
Posts: 35

Hi Srini

It is very much possible to install multiple versions of java in one OS. You will have to point to the right Java version when you run java programs.i.e The version you need.
If you are looking at Sun jdk the link for installables is

Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 238

you can use latest version and you can compile java file from different version from latest version.


javac -target 1.4 *.java
javac -target 1.5 *.java
javac -target 1.6 *.java

The -target 1.4 option ensures that the generated class files will be compatible with 1.4 VMs.

SCJP 6- 91%, IBM DB2, IBM RAD Certified
Shahzad Latif

Joined: Apr 28, 2011
Posts: 28
You can definitely install and use multiple versions of JDK on a single machine/OS. Just install the JDKs into different folders and then change the version when compiling your programs. If you want to test your code using different Java versions, you can create .bat files with various versions and then just execute one of those .bat files before using a particular version. For example, a .bat file for JDK 1.6 might look something like this:

You can name the file as jdk6.bat and then only execute this file before testing your program. You can do the same for other JDK versions.

Developer Evangelist @ Aspose. I love to explore and learn new technologies and help other developers along the way.
srini manassu

Joined: Jan 07, 2012
Posts: 11

Thanks for the links, I really wanted one.

Yeah this is the cool (simple) option, Thanks for letting me know.

I think you are a windows guy the .bat is good, thanks, I don't regularly use windows, but this helped me do some ``work'' with windows
Shahzad Latif

Joined: Apr 28, 2011
Posts: 28

I assumed you were using Java on Windows. My bad!
I agree. Here's the link:
subject: installing multiple versions of java
It's not a secret anymore!