HardwareSimulator Errors on start

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

HardwareSimulator Errors on start

calderete
When trying to start the HardwareSimulator I'm getting

"Error: Unable to initialize main class HardwareSimulatorMain"
"Caused by: java.lang.NoClassDefFoundError: Hack/HardwareSimulator/HardwareSimulatorControllerGUI"

Im on mac OS X Mojave. The results of java -version is

java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

Any help would be much appreciated!
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
There are a couple of things you can try. First, this is an older project, so you may wish to try using Java 8 instead of Java 11.

You can also start the hardware simulator with the following command (from the terminal):

/bin/sh -x ./HardwareSimulator.sh

and copy and paste the output here, to get further help.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
Thank you so much for the help.

The result of running this command '/bin/sh +x ./HardwareSimulator.sh' on
java 11 is -

Error: Unable to initialize main class HardwareSimulatorMain
Caused by: java.lang.NoClassDefFoundError:
Hack/HardwareSimulator/HardwareSimulatorControllerGUI

After switching to 8 by this method -

bash-3.2$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    11.0.1, x86_64: "Java SE 11.0.1"
/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
    1.8.0_73, x86_64: "Java SE 8"
/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home

bash-3.2$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
bash-3.2$ export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
bash-3.2$ java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

And running the same command gives this error -

bash-3.2$ Error: A JNI error has occurred, please check your installation
and try again
Exception in thread "main" java.lang.NoClassDefFoundError:
Hack/HardwareSimulator/HardwareSimulatorControllerGUI
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException:
Hack.HardwareSimulator.HardwareSimulatorControllerGUI
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more






On Tue, Apr 16, 2019 at 1:49 AM ivant [via Nand2Tetris Questions and
Answers Forum] <ml+s32033n4033083h94@n3.nabble.com> wrote:

> There are a couple of things you can try. First, this is an older project,
> so you may wish to try using Java 8 instead of Java 11.
>
> You can also start the hardware simulator with the following command (from
> the terminal):
>
> /bin/sh -x ./HardwareSimulator.sh
>
> and copy and paste the output here, to get further help.
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/HardwareSimulator-Errors-on-start-tp4033082p4033083.html
> To unsubscribe from HardwareSimulator Errors on start, click here
> <http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4033082&code=Y2FsZGVyZXRlMTk4MEBnbWFpbC5jb218NDAzMzA4MnwxNzUwNjM5NTQ0>
> .
> NAML
> <http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
It looks like the classpath isn't set up correctly. Please run it with

sh -x ./HardwareSimulator.sh

and paste the result here.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
The result of running /bin/sh +x ./HardwareSimulator.sh is

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: Hack/HardwareSimulator/HardwareSimulatorControllerGUI

This is using java 8

Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
That's why I asked for -x. This will print out each command that sh is executing.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
this is the full terminal output

bash-3.2$ tools/HardwareSimulator.sh
bash-3.2$ Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: Hack/HardwareSimulator/HardwareSimulatorControllerGUI
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: Hack.HardwareSimulator.HardwareSimulatorControllerGUI
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
I'll try one last time. Here is the way I'm asking to run this, so I can see what's going on, along with the output I'm getting:

$ sh -x tools/HardwareSimulator.sh 
+ unset CDPATH
+ test -L tools/HardwareSimulator.sh
+ echo tools/HardwareSimulator.sh
+ script=tools/HardwareSimulator.sh
+ dir=/tmp/t/nand2tetris
+ dirname tools/HardwareSimulator.sh
+ cd tools
+ [ ( 0 -gt 1 ) -o (  = -h ) -o (  = --help ) ]
+ [ 0 -eq 0 ]
+ java -classpath :bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar HardwareSimulatorMain

So, instead of running just tools/HardwareSimulator.sh, please run: sh -x tools/HardwareSimulator.sh and paste the output.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
I apologize for the misunderstanding. I should have double checked all the text before i sent it. The result is the same if I use "/bin/sh +x ./HardwareSimulator.sh" (see below) I'm executing this command for the tools dir


bash-3.2$ /bin/sh +x ./HardwareSimulator.sh
bash-3.2$ Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: Hack/HardwareSimulator/HardwareSimulatorControllerGUI
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: Hack.HardwareSimulator.HardwareSimulatorControllerGUI
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
You either cannot distinguish between -x and +x or you are trolling.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
In reply to this post by ivant
gotcha. Sorry about that.

with the corrected command the output is

bash-3.2$ /bin/sh -x ./HardwareSimulator.sh
+ unset CDPATH
++ test -L ./HardwareSimulator.sh
++ echo ./HardwareSimulator.sh
+ script=./HardwareSimulator.sh
+ dir=/Users/alderetecharles/nand2tetris/nand2tetris/nand2tetris/tools
++ dirname ./HardwareSimulator.sh
+ cd .
+ '[' '(' 0 -gt 1 ')' -o '(' '' = -h ')' -o '(' '' = --help ')' ']'
+ '[' 0 -eq 0 ']'
+ java -classpath :bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar HardwareSimulatorMain
bash-3.2$ Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: Hack/HardwareSimulator/HardwareSimulatorControllerGUI
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: Hack.HardwareSimulator.HardwareSimulatorControllerGUI
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
In reply to this post by ivant
I assure you I'm not trolling.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
In reply to this post by calderete
calderete wrote
gotcha. Sorry about that.

with the corrected command the output is

bash-3.2$ /bin/sh -x ./HardwareSimulator.sh
+ unset CDPATH
++ test -L ./HardwareSimulator.sh
++ echo ./HardwareSimulator.sh
+ script=./HardwareSimulator.sh
+ dir=/Users/alderetecharles/nand2tetris/nand2tetris/nand2tetris/tools
++ dirname ./HardwareSimulator.sh
+ cd .
+ '[' '(' 0 -gt 1 ')' -o '(' '' = -h ')' -o '(' '' = --help ')' ']'
+ '[' 0 -eq 0 ']'
+ java -classpath :bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar HardwareSimulatorMain
bash-3.2$ Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: Hack/HardwareSimulator/HardwareSimulatorControllerGUI
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: Hack.HardwareSimulator.HardwareSimulatorControllerGUI
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
I can't find anything obviously wrong. There several more things to try:

1. Download and unpack the tools again in a new folder.

2. The path to the scripts looks like this: /Users/alderetecharles/nand2tetris/nand2tetris/nand2tetris/tools. A few years ago Windows had a problem with folder named like its parent folder. I don't know if that's a problem in MacOS, but I'd try moving this just to make sure.

3. If both of the above fail you can run java directly from the tools folder, like this:

java -verbose:class -verbose:jni -classpath :bin/classes:BuiltIn:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Simulators.jar:bin/lib/SimulatorsGUI.jar:bin/lib/Compilers.jar HardwareSimulatorMain | gzip > hwsim.log.gz

You can then send me the logs to see if they'll tel us something more.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

calderete
I have it working now thank you for your help and patience! I believe it may have been a combination of the location and my java 8 install. After moving the file I was still getting errors and the error logs that were produced also had no obvious errors in it. After upgrading from java 1.8.0_73 to 1.8.0_212 the simulator UI was able to start.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
Glad to hear it and have fun with the course.
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

kirti purohit


I am getting  this error after running the comand can you please help me out?
Reply | Threaded
Open this post in threaded view
|

Re: HardwareSimulator Errors on start

ivant
Have you read the messages in the thread above?

Tell us what OS and Java versions you are using. Also copy and paste (not screenshot please) the result of running

/bin/sh -x HardwareSimulator.sh