3

I just installed Oracle JDK 11 on my Windows 10. I noticed that the PATH variable doesn't include the JDK 11 path. Also the .JAR file extension is not associated with javaw. Our users used to doubleclick JAR file to execute the client Java/SWING application. With Java 11 this doesn't work. Is this a bug or feature? I know how to set the PATH and start the application manually using the command line. I just want to make it easier for end-users. Any ideas?

MT0
  • 143,790
  • 11
  • 59
  • 117
stepand76
  • 467
  • 6
  • 17
  • Does the JRE exhibit the same behavior? If you're only going to execute the JARs, you don't need the JDK. – m0skit0 Sep 27 '18 at 12:33
  • 1
    Where I can get public JRE? There is no public JRE in Oracle JDK 11... – stepand76 Sep 27 '18 at 12:46
  • You're correct. That's because Java 11 is still experimental, probably that's why also it doesn't link to JARs at installation time. You can however do it through the OS. – m0skit0 Sep 27 '18 at 12:54
  • 4
    @m0skit0 Java 11 is *not* experimental. It was officially released 2 days ago. – Erwin Bolwidt Sep 27 '18 at 13:00
  • @ErwinBolwidt Sorry maybe I didn't use the correct word: what I mean is there's no stand-alone JRE and Oracle redirects you to Java 8 when you ask for the JDK. – m0skit0 Sep 27 '18 at 13:03
  • 2
    @m0skit0 You can download the Oracle JDK11 right now from https://www.oracle.com/technetwork/java/javase/downloads/index.html - no redirecting to Java 8 at all – Erwin Bolwidt Sep 27 '18 at 13:06
  • 2
    Oracle says "In this release, the JRE or Server JRE is no longer offered. Only the JDK is offered. Users can use jlink to create smaller custom runtimes." (https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#Important_Changes) – Peter Hull Sep 27 '18 at 13:27
  • @PeterHull I don't know jlink, it is new to me. If I understand it allows me to create a custom JRE optimized for my application which is great. But some manual steps is still required on the end-user computer to launch the application. I will still need to have a native utility to make it easier for end users. – stepand76 Sep 27 '18 at 13:54

3 Answers3

3

There is no Public JRE in Java 11, as there was in the previous Java versions. Don't be confused with the jre directory in previous JDK version, it's not a Public JRE. Also installers of the old Public JRE copied the java.exe and the javaw.exe programs into the C:\Windows\System32 directory that is defined in the PATH environment variable by default. They also did many other thing, like changes in your Windows registry. Installers of the old Public JRE had never changed anything in the PATH.

Official alternative to the Public JRE is a custom runtime environment that you can built by the jlink tool of the JDK. However in this case you will have no jar file at all but UNIX shell and Batch scripts.

If you don't like it you may use JDK 11 and associate the jar files in Windows Explorer with javaw.exe of JDK, instead of JRE, as described there Running JAR file on Windows

Rostislav Krasny
  • 577
  • 3
  • 14
  • 2
    I marked this as answer. It lead me to find some information on jlink which probably is a way we will follow - build smaler custom JRE + small native launcher for Windows and a script for Linux. – stepand76 Oct 01 '18 at 14:35
3
  1. Open regedit.exe
  2. Select HKEY_CLASSES_ROOT
  3. Create new key .jar
  4. Type jarfile to default value img
  5. In HKEY_CLASSES_ROOT create new key jarfile
  6. In jarfile create key tree like jarfile DefaultIcon shell open command
  7. [Optional] Type path to icon/executable file to default value in DefaultIcon
  8. Type path to javaw.exe to default value in command like "C:\Java\jdk11\bin\javaw.exe" -jar "%1" img
  9. Now select javaw.exe when opening the program.
1

I made a bat file, which contains the following:

java -jar %1

Click on a jar > open with > select your bat

If java path is set correctly (check with java -version) it will run your jar after double clicking.

Tudor
  • 2,224
  • 2
  • 21
  • 24