acapola
2009-07-11
Hello,
I have hard time with the "HelloWorld" example. Out of many trials, I get it to work once but since that no way...
here is what I tried:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\jasmin-2.3>java -jar jasmin.jar examples\HelloWorld.j
Generated: HelloWorld.class
C:\jasmin-2.3>java examples.HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: examples/HelloWorld
Caused by: java.lang.ClassNotFoundException: examples.HelloWorld
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: examples.HelloWorld. Program will exit.
C:\jasmin-2.3>dir *.class
Volume in drive C has no label.
Directory of C:\jasmin-2.3
07/11/2009 02:25 PM 236 HelloWorld.class
1 File(s) 236 bytes
0 Dir(s) 788,549,632 bytes free
C:\jasmin-2.3>cd examples
C:\jasmin-2.3\examples>dir *.class
Volume in drive C has no label.
Directory of C:\jasmin-2.3\examples
File Not Found
C:\jasmin-2.3\examples>cd..
C:\jasmin-2.3>java HelloWorld
Exception in thread "main" java.lang.VerifyError: (class: HelloWorld, method: ma
in signature: ([Ljava/lang/String;)V) Expecting to find object/array on stack
Could not find the main class: HelloWorld. Program will exit.
C:\jasmin-2.3>java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
Help !
Dan
2009-07-11
Hello,
my first guess would be that you use a too recent JDK. Last time I worked with Jasmin was back in early 2006, and I think I used a JDK version 1.4.
Try running your HelloWorld class with a 1.4 virtual machine and see if that works.
cheers,
dan
acapola
2009-07-11
Hello,
I tried with jre 1.4.2_19 (I realize now that you mentioned jdk, not jre, anyway, as far as I understand, for what I am doing it should not change anything...)
I get still same output:
C:\jasmin-2.3>java -version:1.4.2_19 -jar jasmin.jar examples\HelloWorld.j
Generated: HelloWorld.class
C:\jasmin-2.3>java -version:1.4.2_19 HelloWorld
Exception in thread "main" java.lang.VerifyError: (class: HelloWorld, method: ma
in signature: ([Ljava/lang/String;)V) Expecting to find object/array on stack
is it worth that I try again with the jdk this time ?
Could you give me a full version number with which it is expected to work ?
I aslo tried to rebuild jasmin (with jdk 1.6) but it did not change the problem)
the readme file mention that HelloWorld.class should be created in the examples folder, but in my case it is created in the parent folder (which is the current directory and which contains jasmin.jar) I am doing something wrong or readme file is not accurate ?
Thanks in advance, best regards,
Sebastien
Dan
2009-07-11
> is it worth that I try again with the jdk this time ?
no, testing with the jre is fine
In fact the problem is that HelloWorld.j in jasmin 2.3 is broken, it doesn't even refer to a "Hello World" string. It is broken since version 2.0, I don't know how this slipped in.
Try with the HelloWorld.j from Jasmin 1.1, pasted below:
; --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
; File: jasmin/examples/HelloWorld.j
; Author: Jonathan Meyer, 10 July 1996
; Purpose: Prints out "Hello World!"
; -------------------------------------------------------------------------
.class public examples/HelloWorld
.super java/lang/Object
;
; standard initializer
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 2
; push System.out onto the stack
getstatic java/lang/System/out Ljava/io/PrintStream;
; push a string onto the stack
ldc "Hello World!"
; call the PrintStream.println() method.
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
; done
return
.end method
Note: another way to test Jasmin is to disassemble existing class files, and then reassemble them using Jasmin. Or course you need a disassembler which supports Jasmin syntax for that.
acapola
2009-07-11
Sorted out, many thanks !
Dan
2009-07-11
you're welcome ^^
acapola
2009-07-11
Sorted out, many thanks !