Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] setting java_home on windows 7

the java.home you see in --list-config is from Java itself.
Jetty is not capable of configuring this.

How you start Jetty is important, as essentially you are the one in control of what JVM you want jetty to run under.

For windows, you have to be extra super careful how you setup your environment variables.
Be they system environment or user environment.

User environment seems to override system environment.
Windows is case sensitive here, so use %JAVA_HOME% not %java_home% (this is true even on Windows 8)

Set your JAVA_HOME in your environment to the path of the JVM you want to use..

Here's an example of it on Windows 8.

I start "Command Prompt" (cmd.exe) from the start menu.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\joakim>java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

That shows me that the current default environment is configured for Java 1.7.0_51
Lets see what my environment looks like...

Right click on "My PC" (aka "My Computer" in Windows 7) and choose "Properties" ...

Click on "Advanced System Settings" (only for Windows 8)
I'm staring at a "System Properties" dialog with a few tabs.  In the "Advanced" tab, I choose "Environment Variables..." button.

in my "User variables" section I have no Java, JRE, or JAVA_HOME settings.

In my "System variables" section I have ...

JAVA_HOME = C:\java\jdk1.7.0_51
PATH = %JAVA_HOME%\bin;(the rest of the original PATH)

Its important that your PATH has the %JAVA_HOME%\bin entry before any entry for C:\Windows\system32, as that has the system-wide (managed by the registry and control panel) version of java.exe

If I want to change this to run say 1.7.0_67 I would do the following ...

Stop / exit cmd.exe
Edit the "System variables" section to ...

JAVA_HOME = C:\java\jdk1.7.0_67
(I leave PATH alone, as its based on whatever JAVA_HOME is set to)

Click "OK" to close the "Environment Variables" dialog.
Start a new cmd.exe window and see if it worked...

C:\Users\joakim>java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Yup, it seemed to have worked.
Lets see what Jetty's --list-config shows.

D:\jetty-dist\jetty-distribution-9.2.2.v20140723>java -jar start.jar --list-config
--(snip)--
Java Environment:
-----------------
 java.home = C:\java\jdk1.7.0_67\jre
 java.vm.vendor = Oracle Corporation
 java.vm.version = 24.65-b04
 java.vm.name = Java HotSpot(TM) 64-Bit Server VM
 java.vm.info = mixed mode
 java.runtime.name = Java(TM) SE Runtime Environment
 java.runtime.version = 1.7.0_67-b01
 java.io.tmpdir = C:\Users\joakim\AppData\Local\Temp\
 user.dir = D:\jetty-dist\jetty-distribution-9.2.2.v20140723
 user.language = en
 user.country = US
--(snip)--

Yup. that worked.
Hope this helps you.


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Sat, Aug 9, 2014 at 11:58 AM, Andrew Penhorwood <penhorwood@xxxxxxxxx> wrote:
I am sure I am missing something simple but I can't get jetty 9.2.2 to use the right java_home.  I set the system wide environment variable.  When I run jetty via java -jar start.jar --list-config it reports the java.home as being the jre installed under program files.  The jdk is installed in another location.  The system environment variable is set to the jdk.

I set the follow environment variables and rebooted
java_home = to JDK path
java.home = to JDK path

I added the %java_home%\bin to the path variable.

But jetty still insist on using the java.home in C:\Program Files\Java\jre8

Is the java.home reported by Jetty --list-config set somewhere in the jetty configuration files?

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top