Re: Running a Java Program
Try this (assuming you are on Windows):
java -classpath ".;%CLASSPATH%" test
(Assumes test.class is in the current directory.) NoClassDefFoundError
means exactly that - it can't find the .class file it needs. The reason
is that it's not looking in the current directory, it's looking in the
%CLASSPATH%, which is a system environment variable that points to
someplace on your system. (If you're not sure what an environment
variable is, Google it - this stuff is important when you are
developing in Java). In short, the line above tells java to use "." in
addition to the regular classpath.
HTH,
Greg
On Oct 28, 2:17 pm, "Tim B" <nos...@xxxxxxxxxx> wrote:
"jerry" <jerryc...@xxxxxxxxxxxxx> wrote in messagenews:phv0h.16625$GR.2672@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
When I try to run a JAVA program I have compiled I get the following
error:
Exception in thread "main" java.lang.NoClassDefFoundError: test.
I am in the directory that contains the .class file. Why can't it be
found,
and how can I fix this problem?Java is not an acronym, so it is not spelled 'JAVA'
.
Relevant Pages
- Code Cracking in Java
... Software developers, designers, security professional, auditors, managers responsible for evaluating products. ... I love programming in Java but unfortunately I didn’t get a chance to work in software development firm but I am very much happy with my profile, basically I am an ethical hacker currently working in Wipro and previously in PwC. ... For security reasons I will not mention client name, application vendor and detail about the application architecture. ... As we commonly know that the basic loophole in Java is that it can be reengineered from class file to source code, the class file consist of byte codes which is interpreted by Java Virtual Machine to make Java platform independent. ... (Pen-Test) - Re: java 101 question - how to run a java program
... do "javac java01.java". ... .class file in the same directory as the .java file. ... File "java01.java" not a Java class file. ... Unable to create Java program for "java01.java". ... (comp.sys.ibm.as400.misc) - Re: jar, package and import relationship?
... Java does too: the CLASSPATH must be correct. ... It's a bit different for anything that comes with the default with Java, because the JVM handles those a bit differently with out environment variables, but for any library or .class file you download or create, you need to tell your tools where to find them. ... public static void main(String ... ... (comp.lang.java.programmer) - RE: RH 7.2, J2RE 1.4 and Netscape 7.1
... The reason for some problems between 1.4x and 1.4.2 are class file ... format changes. ... I have had multi issues with some of my prebuilt java ... Netscape may even be doing that. ... (RedHat) - Re: JNI Woes
... I have read include running javah on the class file (which I can ... Writing a wrapper library to implement the functions from the dll to ... and Java does not offer any other technical ... Choose a suitable place for your JNI ... (comp.lang.java.programmer) |
|