Reputation: 29448
I am working on a legacy project with Glassfish 3 and Java 7. The problem is in order to run Eclipse, I need Java 8. When I install Java 8, I can no longer run Glassfish under Java 7 for some reason.
I do see the two JDKs in control panel for User tab in Java Runtime Environment Settings, but under System once I install Java 8, I only see Java 8 there. So it just runs under Java 8 from what I can tell.
This is my first week of Java.
Upvotes: 1
Views: 2005
Reputation: 6103
When you install a new JVM, usually it sets itself as the default version on that platform which is the first one found on the Path
environment variable. In order to find what version is the default one, run this command: java -version
and the output will be something like:
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.10.2-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)
As you see in this case the default one is OpenJDK-8.
If you want to change that, you have to do some changes which depend on the platform can vary but usually you should:
JAVA_HOME
environment variable to point to desired JVM
installation path<installation-path>/bin
to Path
environment variable and remove other JVM paths.(Detailed example for Windows, Example for Ubuntu)
Notice that, this potentially could affect every program that uses Java and does not explicitly reference a specific version of Java in its config.
But If you want the default version to remain intact and only make an exception for some programs you have to do it in their config/settings.
For Example for Eclipse
you can modify eclipse.ini
file and specify the JVM it uses by adding this line (more info):
-vm
/opt/oracle-jdk-1.8.0/bin/java
or for Windows:
-vm
C:\Java\JDK\1.8\bin\javaw.exe
there is a similar config for glassfish
too. You can choose which JVM should be the default version and which the one exceptional programs gonna use, In your case I recommend that keep version 7 as default and change eclipse config to use version 8.
Upvotes: 1
Reputation: 5828
Simply specify the needed JDK for your Glassfish domain:
C:\servers\glassfish\config\asenv.bat
(this path is an example)Edit the file, comment the previous JDK and add the wanted one:
REM set AS_JAVA=C:\Program Files\Java\jdk1.8\..
set AS_JAVA=C:\Program Files\Java\jdk1.7\..
Upvotes: 1