简体   繁体   中英

Runnable .jar working on Ubuntu but not Windows

This is how pressing the submit button from the .jar run from cmd looks like on Windows:

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

C:\Users\Vlad>java -jar run.jar
java.lang.NullPointerException
        at MemoryFileManager.<init>(MemoryFileManager.java:15)
        at MemoryClassLoader.<init>(MemoryClassLoader.java:12)
        at MemoryClassLoader.<init>(MemoryClassLoader.java:15)
        at Main.run(Main.java:130)
        at GUI$2.mouseClicked(GUI.java:185)
        at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$400(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

The MemoryClassLoader and MemoryFileManager classes that appear for the raised exception are from here: https://sites.google.com/site/malenkov/java/081217
Specific lines are:
Line 12 in MemoryClassLoader :

private final MemoryFileManager manager = new MemoryFileManager(this.compiler);

Line 15 in MemoryClassLoader :

this(Collections.singletonMap(classname, filecontent));

and Line 15 in MemoryFileManager :

super(compiler.getStandardFileManager(null, null, null));  

Seeing that the program runs correctly from Eclipse and on Ubuntu I'm guessing it has something to do with paths to the javax.tools imports? At a certain point in the project I remember making eclipse move from using JRE to using JDK because of errors regarding to those same classes. What do I need to do to make it run on Windows? I'm sorry if it's a stupid question of if it's obvious :p
Thank you!

compiler is null in MemoryClassLoader.<init>(MemoryClassLoader.java:12) . ToolProvider.getSystemJavaCompiler() returns null if there isn't any compiler.

Seems like you indeed need to have JDK installed to run this (or at least the tools.jar on the classpath): ToolProvider.getSystemJavaCompiler() returns null - usable with only JRE installed?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM