The Artima Developer Community
Sponsored Link

Java Answers Forum
Some JVM Problem

4 replies on 1 page. Most recent reply: Apr 20, 2002 9:42 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Binod Pokharel

Posts: 9
Nickname: binod
Registered: Mar, 2002

Some JVM Problem Posted: Apr 19, 2002 7:44 AM
Reply to this message Reply
Advertisement
I ahve jdk 1.4 installed on my machine. I think I have set the path and the classpath properly.

Now if I compile any java file from dos mode it does that fine. But if I want to run it using java <filename<; it everytime throws me the following error.

Exception in thread "main" java.lang.NoClassDefFoundError:<filename>

Please let me know if someone has faced this problem.

Bye
Binod


Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

Re: Some JVM Problem Posted: Apr 19, 2002 7:58 AM
Reply to this message Reply
You might want to look at http://mindprod.com/errormessages.html for a summary of causes of this error(look under NoClassDefFoundError)...

Lynn.

Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: Some JVM Problem Posted: Apr 19, 2002 8:06 AM
Reply to this message Reply
I think you have classpath problem for your class. You can test your program as follows.
1. Suppose you have created a class Test and you have placed you java file in c:\java\Test.java. I am assuming that you haven't placed Test class in any package.
2. Compile your class Test and your then you get c:\java\Test.class
3. Make your current directory as c:\java and then use the following command
c:\java> java -cp "." Test

If you get any probelm in STEP 3 it means you have some problem in JDK 1.4 installation and you need to re-install it.

Thanks
Kishori

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Some JVM Problem Posted: Apr 20, 2002 7:00 PM
Reply to this message Reply
Hey,
also try the command set
and it will list all your environment variables.
One of these should be CLASSPATH

Pick out the line that starts with CLASSPATH=
All the entries are separated with a semicolon ;
and define how javac and java programs will find the class it needs.

The entry that looks like ;.;
stands for the cuurent working directory

The output of mine looks like:


C:\j2sdk1.4.0\projects\MessageDigestComputer>set
PROMPT=$p$g
TEMP=C :\WINDOWS\TEMP
TMP=C:\WINDOWS\TEMP
COMSPEC=C:\WINDOWS\COMMAND.COM
JAVA_HOME=C:\j 2sdk1.4.0
JMFHOME="C:\PROGRAM FILES\JMF2.1.1"
SPEECH=C:\j2sdk1.4.0\FreeTTS\lib\JSAPI.JAR;C:\j2sdk1.4.0\FreeTT S\lib\freetts.jar
;C:\j2sdk1.4.0\FreeTTS\lib\cmulex.jar;C:\j2sdk1.4.0\FreeTTS\li b\cmukal8.jar;C:\j
2sdk1.4.0\FreeTTS\lib\cmukal16.jar;C:\j2sdk1.4.0\FreeTTS\lib\ cmuawb.jar;C:\j2sdk
1.4.0\FreeTTS\lib\cmutimelex.jar
CLASSPATH=C:\PROGRA~1\JMF21 ~1.1\LIB\SOUND.JAR;C:\PROGRA~1\JMF21~1.1\LIB\JMF.JAR;
.;C:\J2SDK1.4.0\JAVAMAIL-1 .2\MAIL.JAR;C:\J2SDK1.4.0\JAF-1.0.1\ACTIVATION.JAR;C:\
J2SDK1.4.0\MYTOOLS;C:\J2S DK1.4.0\FREETTS\LIB\JSAPI.JAR;C:\J2SDK1.4.0\FREETTS\LIB
\FREETTS.JAR;C:\J2SDK1.4 .0\FREETTS\LIB\CMULEX.JAR;C:\J2SDK1.4.0\FREETTS\LIB\CMUK
AL8.JAR;C:\J2SDK1.4.0\F REETTS\LIB\CMUKAL16.JAR;C:\J2SDK1.4.0\FREETTS\LIB\CMUAWB.
JAR;C:\J2SDK1.4.0\FREE TTS\LIB\CMUTIMELEX.JAR;"C:\PROGRAM FILES\JMF2.1.1\lib\jmf.
jar";"C:\PROGRAM FILES\JMF2.1.1\lib\sound.jar";
DBROOT=C:\Adabas
DBWORK=C:\Adabas\sql
DBCONFIG=C :\Adabas\sql
PATH=.;C:\WINDOWS;C:\WINDOWS\COMMAND;c:\j2sdk1.4.0\bin;c:\j2sdk1.4. 0\lib;c:\j2sd
k1.4.0\jre\bin\client;c:\j2sdk1.4.0\MyTools;C:\j2sdk1.4.0\SrcHighl ite\bin;C:\EA\
GAMBIT;c:\Borland\BCC55\bin;C:\Adabas\bin;C:\Adabas\pgm;C:\PJEE3. 1\BIN;C:\PROGRA
~1\NETWOR~1\PGP
winbootdir=C:\WINDOWS
windir=C:\WINDOWS
BLASTER= A220 I5 D1 T4 P330
CMDLINE=java MessageDigestComputer

C:\j2sdk1.4.0\projects\MessageDigestComputer>


Once you get classpath and path straight java programming will become much easier.

Charles

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Some JVM Problem Posted: Apr 20, 2002 9:42 PM
Reply to this message Reply
I had this same error message from a different quarter once and it took me a while to figure it out. I had created a class with a main() in the current directory, but when I tried to run it, I got that message. It turned out that this same class already existed elsewhere (earlier) in the classpath, so that was the one it was trying to run. Since that one didn't have a main(), it wouldn't run. It can be very vexing, since everything appears to be fine and other classes in the current directory can be executed.

Flat View: This topic has 4 replies on 1 page
Topic: how to print(send to a printer) out html Previous Topic   Next Topic Topic: lightless line

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use