JamVM NoClassDefFoundError when main is inside of a package

759 Views Asked by At

I am getting a NoClassDefFoundError, class file has wrong name, when I try to put HelloWorld in a package! I am using Jamvm v1.5.2. I am assuming my class paths are set correctly because I am able to run when HelloWorld is not in a package... How do I get a main to run inside of a package with jamvm? What path do I need to set for this to work? Thanks.

Hello.java:

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

root@overo:~/default# jamvm Hello
Hello gumstix.

Hello.java:

package test.com;

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

root@overo:~/test# jamvm Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Caused by: java.lang.NoClassDefFoundError: class file has wrong name

1

There are 1 best solutions below

0
kajacx On

Not sure if you have package test.com;, but if you had package test; try moving the Hello.class file to a folder named "test" and then write

root@overo:~/default# jamvm test.Hello

from directory where yout "test" folder is.

Works on Windows with standart Java SE version, hope it will work for you too.