• Post Reply Bookmark Topic Watch Topic
  • New Topic

Alternate between Java versions on Windows (8.1)?  RSS feed

 
Mark Jame
Greenhorn
Posts: 28
Java Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have several versions of Java installed.

Considering parts of the JRE and JDK are added to the PATH, and that Oracle has now added C:\ProgramData\Oracle\Java\javapath (what is this?) to the PATH; is there an easy way with a script of some sort to quicky alternate between Java versions?

The main objective is to change Java version (for both compiling and running) possibly several times a day without rebooting.

I normally use Cygwin for command line stuff on Windows but could resort to a DOS box if needed.

In an ideal world I would use seveal versions at the same time, for example two cygwin (or DOS) windows, one with Java 7 and one with Java 8; if that's not possible then I could use a single window to dynamically switch version.

Anyone know if/how this can be done?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using javac, there is a possibility to specify the source and target. you should probably specify this to whichever build process issues the javac command to compile your sources.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the PATH for the current command line with
set PATH="\C:Program Files\Java\jdk1.9.0_999\bin";%PATH%
or something like that. You can actually have two command lines with different PATHs running simultaneously.
 
Mark Jame
Greenhorn
Posts: 28
Java Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not had time to look at this in more detail yet, but trying to compile for 1.7 gives a warning (I prefer not to have any warnings):

What is this?

I will look at changing the path next.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!