What is wrong with my batch file?

I am trying to make an MS-DOS batch file that runs a .class file from Java source code. It is complicated to get it to work because it uses a package that is not native to Java (meaning that it does not have the format: "import java.x.y.z;"). The program I made uses the package BreezySwing, which is sometimes called "easy GUI" because it is basically a simplified version of the Java GUI package. However, that does not matter that much; what matters is that my program needs a foreign package that is not part of the JDK. Here is my batch file so far, the program is called AddFields:

@echo off
cd \acorn
set path=C:\Program Files\Java\jdk1.6.0_07\bin
set classpath=.
java AddFields
pause

The directory (where the .class file is located) for the file "AddFields.class" is located in C:\acorn.

When I run this batch file, I get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: BreezySwing/GBFrame

Can you please instruct me on how to fix this? Will give best answer and thumbs up points for most useful and detailed answer.

Joe L2009-05-15T19:31:58Z

Favorite Answer

The GBFrame class is in a .jar file, I guess? Where is the .jar file? You need to add it to your classpath. If the jar file is Breezy.jar in the same directory, then put this in your batch file:

java -cp .;Breezy.jar

The -cp parameter create the CLASSPATH for you so you don't need to do the set. You can see that i included the current directory & the JAR by separating them with a semicolon.

Also, if you create the environment variable JAVA_HOME you don't need to put the JRE in the PATH.