1

Trying to execute myApp based on ChronicleMap API:

java -jar myApp-00.00.01-SNAPSHOT-jar-with-dependencies.jar

and getting exception.

Exception in thread "main" java.lang.AssertionError: java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
    at net.openhft.chronicle.values.CompilerUtils.reset(CompilerUtils.java:62)
    at net.openhft.chronicle.values.CompilerUtils.<clinit>(CompilerUtils.java:51)
    at net.openhft.chronicle.values.ValueModel.createClass(ValueModel.java:348)
    at net.openhft.chronicle.values.ValueModel.createHeapClass(ValueModel.java:327)
    at net.openhft.chronicle.values.ValueModel.heapClass(ValueModel.java:317)
    at net.openhft.chronicle.values.Values.heapClassFor(Values.java:68)
    at net.openhft.chronicle.values.Values.newHeapInstance(Values.java:37)
    at com.twi.lib.ev.ipc.VTORId.<clinit>(VTORId.java:189)
    at com.twi.lib.ev.ipc.Ipc.initialize(Ipc.java:294)
    at com.twi.lib.ev.base.Preferences.areRequiredPreferencesSet(Preferences.java:356)
    at com.twi.lib.ev.base.ApiEv.autoinitialize(ApiEv.java:48)
    at com.twi.demo.ev_examples.Main.main(Main.java:116)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at net.openhft.chronicle.values.CompilerUtils.reset(CompilerUtils.java:58)
    ... 11 more

Here is my config:

OS Installed: Windows 10

Java Installed: JDK 1.8.0_131

Java Path: C:\Program Files\Java\jre1.8.0_131\bin\javaw.exe

ChronicleMaps tested: 3.10 - 3.13 - same problem for all these versions

MyApp runs fine under Netbeans 8.2 but this exception always comes up if trying to run in command window and command:

java -jar myApp-00.00.01-SNAPSHOT-jar-with-dependencies.jar

What is wrong?

Missing jar library JavacTool ? Compatibility? Bug in ChronicleMap?

Thank you for any input for getting myApp running with command:

java -jar myApp.jar
Felix
  • 1,662
  • 2
  • 18
  • 37

2 Answers2

2

Got it working. Here is how in case someone else struggles with Windows and java configuration.

If you want to run your jar application (with the ChronicleMap API) the standard java way - e.g:

java -jar myApp.jar

you must make sure your executing "java" is the JDK java and not JRE java.

This means you and your app. users will need to have JDK installed on your system and configured so that the JDK java is used, not the JRE java.

That's been clear to me from beginning, and I thought my system was running JDK java, but it did not. Here is how I solved it.

In Windows (after you have installed JDK) you may have several locations/folders specified in your system environment variables as the PATH to java.exe.

In my case I had 3 references to java. You can check that from command line:

where java

My result was:

C:\Program Files\Java\jre1.8.0_131\bin
C:\Program Files\Java\jdk1.8.0_131\bin
C:\ProgramData\Oracle\Java\javapath

As advised by others I added: JAVA_PATH variable and pointed it to: C:\Program Files\Java\jdk1.8.0_131

But that did not solve the issue and I was still running JRE, not JDK java.

I also checked the java control panel ("Configure Java" in start menu item). First of all note that you must run it as administrator or no changes will stick - that's what Oracle says. But for me after a reboot the settings were all back to defaults and all my changes gone.

In case it works for you here are the steps:

  • Windows start menu
  • right-click "Configure Java"
  • More > Run as administrator
  • enter your admin. password (if you do not see the password window, look for the icon on your task bar)
  • Java Control panel will appear
  • select tab: Java
  • click: View
  • select tab: System
  • click: Find and navigate to your java JDK folder - e.g: C:\Program Files\Java\jdk1.8.0_131\bin
  • click: Next
  • you'll see: C:\Program Files\Java\jdk1.8.0_131\bin\javaw.exe
  • click: Finish
  • enable the added entry check-box and disable all others
  • OK, OK

Now, this was supposed to specify my preference of JDK java over JRE java. But it did not.

So, at the end I removed all references to java in my PATH - Windows system environment variables except the one for JDK: C:\Program Files\Java\jdk1.8.0_131\bin

That did it.

Felix
  • 1,662
  • 2
  • 18
  • 37
0

@Felix's answer works. But note, if you're currently running in vscode, you'd need to close and reopen it before it works.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 28 '22 at 17:53
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32341944) – ahuemmer Jul 30 '22 at 15:40