Can't run classes in packages

Using the Java SDK with TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
Fenring
Posts: 1
Joined: Tue Feb 23, 2010 8:05 pm

Can't run classes in packages

Post by Fenring »

I recently switched to Windows 7, and now, after moving all my Java programs over, my classes in packages will no longer run. I can access them, but if my main method is in a class in a package, I get the following a NoClassDefFoundError.

Code: Select all

package MyPackage;

public class MyClass{

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

}

Code: Select all

Exception in thread "main" java.lang.NoClassDefFoundError: MyClass (wrong name: MyPackage/MyClass)"
I've tracked the problem down to the fact that the parameters field for my "Run Java Application" tool is just $BaseName, so that it is effectively calling

Code: Select all

java MyClass
when java is expecting

Code: Select all

java MyPackage.MyClass
I've tried using the latter from the command line and it works.

Is there any way to get get TextPad to include the package, or to convince java that it doesn't need it?
Post Reply