0

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!

Vlad Vidac
  • 978
  • 1
  • 10
  • 26

1 Answers1

2

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?

Community
  • 1
  • 1
molnargab
  • 162
  • 7
  • Thank you! I'm pretty sure I have JDK installed though, since I used it to run the program in Eclipse. Do I need to do anything other than have it installed if I want to keep using JavaCompiler? – Vlad Vidac Mar 14 '15 at 13:33
  • 1
    As long as you have it on the classpath it should run fine. If you have multiple editions of Java installed, it may be an issue that the JRE is on the PATH. Also Eclipse has its own compiler, it may as well be returned. – molnargab Mar 14 '15 at 22:12