Runnable .jar 在 Ubuntu 但不在 Windows 上工作
Runnable .jar working on Ubuntu but not Windows
这是在 Windows 上从 cmd 运行 从 .jar 按提交按钮的样子:
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.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.access0(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain.doIntersectionPrivilege(Unknown Sour
ce)
at java.security.ProtectionDomain.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.run(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain.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)
出现的异常的MemoryClassLoader
和MemoryFileManager
类来自这里:https://sites.google.com/site/malenkov/java/081217
具体线路为:
MemoryClassLoader
中的第 12 行:
private final MemoryFileManager manager = new MemoryFileManager(this.compiler);
MemoryClassLoader
中的第 15 行:
this(Collections.singletonMap(classname, filecontent));
和 MemoryFileManager
中的第 15 行:
super(compiler.getStandardFileManager(null, null, null));
从 Eclipse 和 Ubuntu 上看到程序 运行 是正确的,我猜它与 javax.tools 导入的路径有关?我记得在项目的某个时刻,由于与 类 有关的错误,我将 eclipse 从使用 JRE 转移到使用 JDK。我需要做什么才能在 Windows 上达到 运行?很抱歉,如果这是一个愚蠢的问题,它是否显而易见:p
谢谢!
compiler
在 MemoryClassLoader.<init>(MemoryClassLoader.java:12)
中为空。
ToolProvider.getSystemJavaCompiler() returns 如果没有任何编译器,则为 null。
似乎您确实需要将 JDK 安装到 运行 这个(或者至少是类路径上的 tools.jar):
ToolProvider.getSystemJavaCompiler() returns null - usable with only JRE installed?
这是在 Windows 上从 cmd 运行 从 .jar 按提交按钮的样子:
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.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.access0(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain.doIntersectionPrivilege(Unknown Sour
ce)
at java.security.ProtectionDomain.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.run(Unknown Source)
at java.awt.EventQueue.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain.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)
出现的异常的MemoryClassLoader
和MemoryFileManager
类来自这里:https://sites.google.com/site/malenkov/java/081217
具体线路为:
MemoryClassLoader
中的第 12 行:
private final MemoryFileManager manager = new MemoryFileManager(this.compiler);
MemoryClassLoader
中的第 15 行:
this(Collections.singletonMap(classname, filecontent));
和 MemoryFileManager
中的第 15 行:
super(compiler.getStandardFileManager(null, null, null));
从 Eclipse 和 Ubuntu 上看到程序 运行 是正确的,我猜它与 javax.tools 导入的路径有关?我记得在项目的某个时刻,由于与 类 有关的错误,我将 eclipse 从使用 JRE 转移到使用 JDK。我需要做什么才能在 Windows 上达到 运行?很抱歉,如果这是一个愚蠢的问题,它是否显而易见:p
谢谢!
compiler
在 MemoryClassLoader.<init>(MemoryClassLoader.java:12)
中为空。
ToolProvider.getSystemJavaCompiler() returns 如果没有任何编译器,则为 null。
似乎您确实需要将 JDK 安装到 运行 这个(或者至少是类路径上的 tools.jar): ToolProvider.getSystemJavaCompiler() returns null - usable with only JRE installed?