Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

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.

1 Answer

Relevance
  • Joe L
    Lv 4
    1 decade ago
    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.

Still have questions? Get your answers by asking now.