Reply
Thread Tools
Posts: 15 | Thanked: 0 times | Joined on Nov 2008
#1
Hey there!

I'm having a problem executing a java program on the tablet. I've following the guide on the maemo site, so installed cacao and the gnu classpath.

I have the following simple code

Code:
public class Main 
{
	public static void main(String[] args) {
                System.out.println("Hello Jalimo");
	}
}
I compile this, transfer ONLY Main.class over to my device and find this in the filesystem. Then I tap:

Code:
cacao Main
then an exception is thrown without printing out the "hello jalimo":

Code:
Exception in thread "main" java.lang.NoClassDefFoundError: 
Main (wrong name:test810.Main)
...
Anybody got any ideas what's up? where could this "wrong name" be? I can run the packaged jalimo-console-example fine so jalimo does work.
 
pixelseventy2's Avatar
Posts: 357 | Thanked: 115 times | Joined on Sep 2007 @ Sunny England :)
#2
what is the name of the class file you are executing? In java the class name must match the file name, ie a file with a class called Bob must be called Bob.class. Also, if you try and run "cacao folder/Main" it is going to look for a java class with the declaration "package folder" at the top.
__________________
pixel - pushing buttons that shouldn't be pushed, and fiddling with things that shouldn't be fiddled with
 
Posts: 41 | Thanked: 13 times | Joined on Oct 2008
#3
Hello. You need to point your classpath and then always write current folder:
for example, if I use glibj.jar, then
export CLASSPATH=/usr/share/classpath/glibj.zip:.
cacao -cp /usr/share/classpath/glibj.zip:. Main
 
Posts: 15 | Thanked: 0 times | Joined on Nov 2008
#4
@pixelseventy2 - The name of the class file is Main.class so that matches the actual class name. The class is in the default package I guess (in that I didn't explicitly put it in one)

@shanti - Below is what I entered, the current directory /home/user/MyDocs/.documents is where the class file resides.

Code:
/home/user/MyDocs/.documents # export CLASSPATH=/home/user/MyDocs/.documents/Main.class:.

/home/user/MyDocs/.documents # cacao -cp /home/user/MyDocs/.documents/Main.class:. Main
...and I get the same result. Any other ideas what could be happening? is the path you mention significant?
 
Posts: 1 | Thanked: 0 times | Joined on Nov 2008
#5
Hi dunff2k,

Did you by accident provide a line like
package test810;
in the beginning of the java file? If yes, try to remove that line and re-compile. If the class is in a package, you would have to put the class file into a folder with the package name and call the file with
cacao test810.Main
with you being in the folder holding the folder 'test810'.

Good luck,
Helmuth
 
Posts: 15 | Thanked: 0 times | Joined on Nov 2008
#6
@hbr - You're right but in a new version of the class file I copied to the device that is no longer the case, yet the error still refers to test810.Main. The file executes fine from the command line on my windows machine using:

Code:
java Main
..when I am currently in the same directory as Main.class (no sign of test810). could there be some pointer somewhere still looking at this package?

So now I'm left wondering what this means
Code:
export CLASSPATH=/usr/share/classpath/glibj.zip:.
cacao -cp /usr/share/classpath/glibj.zip:. Main
What is glibj.zip? What does the classpath point to? and what directory should I be in to execute the cacao command.

Thanks for your patience with this...
 
Posts: 41 | Thanked: 13 times | Joined on Oct 2008
#7
Originally Posted by dunff2k View Post
What is glibj.zip? What does the classpath point to? and what directory should I be in to execute the cacao command.
I assumed, that you compiled (javac) in current directory. And run program in current directory. For example, you copy your Main.class in ~/myjava/Main.class. Then you make "cd ~/myjava/". Then you make:
export CLASSPATH=/usr/share/classpath/glibj.zip:.
cacao -cp /usr/share/classpath/glibj.zip:. Main

glibj.zip is package with classes, that are necessary for realtime running java program. In Sun's java or OpenJDK its rt.zip. In Jalimo installation, as I remember it must be glibj.zip. Have you this file?
Meanwhile, there is java compiler for Maemo. Try Google "maemo jikes"
 
Posts: 15 | Thanked: 0 times | Joined on Nov 2008
#8
OK I seem to have got non GUI java apps working thanks for your input , I can only assume I had too many files of the same name hanging around and was confused.

Now I'm trying to get a GUI based one working as in the SimpleSwtSample on the jalimo site. And running the suggested code on the site gives me a problem.

Code:
cacao -cp /usr/share/java/swt-gtk.jar SimpleSwtSample
Where SimpleSwtSample is a class file in the current directory (along with one other that is generated). And swt-gtk.jar actually exists at the path suggested.

The error message I get is:

Code:
SimpleSwtSample not found in java.lang.classloader$1{urls=[file:/usr/share/java/swt-gtk.jar], parent = null}
Which makes sense because I didn't put that class file in swt-gtk.jar which I presume holds the GUI libraries?

Any ideas what it requires of me?
 
Posts: 41 | Thanked: 13 times | Joined on Oct 2008
#9
It seems, you forgot one:
cacao -cp /usr/share/java/swt-gtk.jar:. SimpleSwtSample

You need always point your current dir in classpath- ":.".
 
Posts: 15 | Thanked: 0 times | Joined on Nov 2008
#10
Hey thanks again for the response...

That advances things but upon selecting enter I'm greeted with lots of screens of the same error:

Code:
dumping the current stack trace.  We received a SIGSEGV and
tried to handle it but we were unable to find java method at PC=0x401020c8
with the final word being:

Code:
segmentation fault
ouch. Doesn't seem to much info on what this means, any ideas?
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 22:04.