Skip to main content

Hello World compiled using java6

10 replies [Last post]
mirza2m
Offline
Joined: 2008-12-04
Points: 0

Hi,
I am having a tough time running a simple hello world program. I get a class not found exception even though I pass the correct class path using -cp: option. So I guess the first question is can I run regular java byte code on squawk. If I can how?

Thank you

babar

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mirza2m
Offline
Joined: 2008-12-04
Points: 0

> Post the error message.
babar@babar-laptop:~/squawk$ java -cp /home/babar/workspace/HelloWord/bin edu.testing.Main
HellO World
babar@babar-laptop:~/squawk$ squawk -cp:/home/babar/workspace/HelloWord/bin edu.testing.Main
No such class edu.testing.Main: java.lang.ClassNotFoundException: edu.testing.Main

--------------------------------------------------------------------
Hits - Class:91.37% Monitor:76.96% Exit:100.00% New:94.20%
GCs: 0 full, 0 partial
** VM stopped: exit code = 999 **

please note java with same cp works

Thank you

babar

kingpommes
Offline
Joined: 2008-11-12
Points: 0

Hi babar,

try to use [i]"[b]./d user-compile[/b] /home/babar/workspace/HelloWord"[/i] to compile your source code.
Start your program with the classes created by the script. Example:[i] "squawk -cp:/home/babar/workspace/HelloWord/[b]j2meclasses[/b] edu.testing.Main"[/i]
I think the script will not affect the class files in the "bin" folder, so don't use them.

Dennis

mirza2m
Offline
Joined: 2008-12-04
Points: 0

Thank you for your reply Dennis.

I did as you said but still get the same error. So I ran with veryverbose option and got some more deatils in the stack trace below. It seems to be saying that dynamic loading is not turned on, but build.properites does have

ENABLE_DYNAMIC_CLASSLOADING=true

babar@babar-laptop:~/trunk$ ./d user-compile /home/babar/workspace/HelloWord
Launcher: Found tools.jar in /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/lib/tools.jar, by popping up a level from jre.
Builder.JDK: Looking for JDK in /usr/lib/jvm/java-1.5.0-sun-1.5.0.16, popped up a level from jre
Launcher: Found tools.jar in /usr/lib/jvm/java-1.5.0-sun-1.5.0.16/lib/tools.jar, by popping up a level from jre.
For vm2c tools.jar=/usr/lib/jvm/java-1.5.0-sun-1.5.0.16/lib/tools.jar
[running user-compile...]
Compiling user project at /home/babar/workspace/HelloWord
Total time: 0s

babar@babar-laptop:~/trunk$ ./squawk -cp:/home/babar/workspace/HelloWord/j2meclasses/ -veryverbose edu.testing.Main
[initializing class java.lang.Integer]
[initializing class com.sun.squawk.Klass]
[initializing class java.lang.Integer]
[initializing class java.lang.System]
[initializing class javax.microedition.io.Connector]
[Klass.forName(com.sun.squawk.io.j2me.debug.Protocol)]
[Klass.forName(com.sun.cldc.i18n.j2me.ISO8859_1_Writer)]
[Klass.forName(com.sun.cldc.i18n.j2me.ISO8859_1_Writer)]
[Starting isolate for 'edu.testing.Main' with class path set to '/home/babar/workspace/HelloWord/j2meclasses/' and leaf suite 'suite -leaf5- [closed: false, parent: squawk]']
[Klass.forName(edu.testing.Main)]
[Klass.forName(com.sun.squawk.io.j2me.file.Protocol)]
[Klass.forName(com.sun.squawk.io.j2me.channel.Protocol)]
[initializing class com.sun.squawk.io.j2me.channel.Protocol$ChannelID]
[Klass.forName(javax.microedition.io.ConnectionNotFoundException)]
[translator not found - dynamic class loading disabled]
No such class edu.testing.Main: java.lang.ClassNotFoundException: edu.testing.Main

--------------------------------------------------------------------
Hits - Class:91.77% Monitor:85.13% Exit:100.00% New:94.50%
GCs: 0 full, 0 partial
** VM stopped: exit code = 999 **

I also explicitly turned on hosted mode and got

Assertion failed: insufficient memory to start VM
fatalInterpreterError com_sun_squawk_VM_fatalVMError -- vmcore/src/vm/squawk.c:1536
opcode: b4
ip: b0e4d6e2. Is in code range b0e3e000 .. b1e87000
stack: b1e87008. Is NOT in RAM range b1687000 .. b1e87000
current stack is service stack
sp: b1e8cf4c. Is NOT in current stack range b1e8701c .. b1e88804
fp: b1e8cf4c. Is NOT in current stack range b1e8701c .. b1e88804

--------------------------------------------------------------------
Hits - Class:0% Monitor:0% Exit:0% New:100.00%
GCs: 0 full, 0 partial
** VM stopped: exit code = -1 **

Message was edited by: mirza2m

kingpommes
Offline
Joined: 2008-11-12
Points: 0

Try to create a suite file:
./d rom -metadata cldc debugger
./d romize -metadata -parent:squawk -o:HelloWorld -cp:../HelloWorld/j2meclasses ../HelloWorld/j2meclasses

Start your program within the suite file:
./squawk -suite:HelloWorld edu.testing.Main

Dennis

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Did you notice the error

No such class edu.testing.Main: java.lang.ClassNotFoundException: edu.testing.Main

In your above log, is this the class that you are trying to run ? If so, then it could be we have a bug that causes the VM to crash if the starting class is not present ? Is that class in the class path you specified ?

Please note, that unfortunately you cannot use the Squawk builder with Java 6 at the moment :( So id you are using the d scrips from above, make sure you are on Java 5.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

How are you trying to run this code ?

Its not as easy as we would like to create a Hello World program and get it running. I think we have instructions on our wiki, but not sure right now.

mirza2m
Offline
Joined: 2008-12-04
Points: 0

Thank you for your reply

package edu.testing

public class HelloWord{

public static void main(String args[])
{
System.out.println("Hello World!");
}

}

compiled using eclipse than

in ubuntu 8 terminal cd to squawk build folder I use the following command

squawk -cp:[class path] edu.testing.HelloWorld and I get class not found exception

also I verified this works

java -cp [class path] edu.testing.HelloWorld

babar

kingpommes
Offline
Joined: 2008-11-12
Points: 0

Which class cannot be found? [i]HelloWorld[/i] or [i]System[/i]?

Post the error message.

Dennis

mirza2m
Offline
Joined: 2008-12-04
Points: 0

Thank you for your reply Dennis

I don't have access to squawk right now but as soon as I do I will post the error. I am 90% sure that the problem was finding HelloWorld, but in general, Is it ok to run java code over squawk?

Another question
If I add squawk install path to PATH os variable squawk complains about having problems with Channel. Is this normal? Again I don't have the error stack trace but I will post that soon.

Thank you

babar

mirza2m
Offline
Joined: 2008-12-04
Points: 0

> Another question
> If I add squawk install path to PATH os variable
> squawk complains about having problems with Channel.
> Is this normal? Again I don't have the error stack
> trace but I will post that soon.
babar@babar-laptop:~$ squawk -cp:/home/babar/workspace/HelloWord/bin edu.testing.Main
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/squawk/vm/ChannelIO
Can't find com.sun.squawk.vm.ChannelIO

--------------------------------------------------------------------
Hits - Class:0% Monitor:0% Exit:0% New:0%
GCs: 0 full, 0 partial
** VM stopped: exit code = -1 **