AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problem running an application from command line

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Joan
Guest





PostPosted: Tue Jan 27, 2004 4:34 pm    Post subject: problem running an application from command line Reply with quote



I have a .java file created using JCreator LE. I am able to compile
and run it from JCreator LE. But When I tried to do the same thing
from command line, I am able to compile it but got
"java.lang.NoClassDefFoundError" when I tried to run it (and it seems
that it doesn't matter which directory I am in).

Any idea why this is happening?

Thanks for your help.

Joan
Back to top
Chris Smith
Guest





PostPosted: Tue Jan 27, 2004 4:40 pm    Post subject: Re: problem running an application from command line Reply with quote



Joan wrote:
Quote:
I have a .java file created using JCreator LE. I am able to compile
and run it from JCreator LE. But When I tried to do the same thing
from command line, I am able to compile it but got
"java.lang.NoClassDefFoundError" when I tried to run it (and it seems
that it doesn't matter which directory I am in).

Any idea why this is happening?

Where are your source files? What are your relevant environment
variables? What directory are you compiling from? (I know you said
you've tried several, but pick one that you think should work.) Where
is the J2SDK installed, and what version is it?

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Back to top
Mark Haase
Guest





PostPosted: Tue Jan 27, 2004 10:31 pm    Post subject: Re: problem running an application from command line Reply with quote



In article <39d54693.0401270834.242dd111 (AT) posting (DOT) google.com>,
[email]joan48105 (AT) yahoo (DOT) com[/email] (Joan) wrote:

Quote:
I have a .java file created using JCreator LE. I am able to compile
and run it from JCreator LE. But When I tried to do the same thing
from command line, I am able to compile it but got
"java.lang.NoClassDefFoundError" when I tried to run it (and it seems
that it doesn't matter which directory I am in).

Any idea why this is happening?

You really ought to paste the full error, and provide more details.

But the most common cause for newbies getting this error is they do the
following:

Quote:
javac MyClass.java

java MyClass.class

When you invoke the java command, it knows to append ".class" when
looking for the class file.

Corrected:

Quote:
java MyClass

--
Quote:
/| /| |2 |
mehaase(at)sas(dot)upenn(dot)edu


Back to top
Andrew Thompson
Guest





PostPosted: Wed Jan 28, 2004 2:34 am    Post subject: Re: problem running an application from command line Reply with quote

"Joan" ...
Quote:
I have a .java file

To add to what Chris and Mark were
saying (don't you love usenet? Wink )..

java -cp . TheClass

--
Andrew Thompson
* http://www.PhySci.org/codes/ Web & IT help
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site



Back to top
Andrew Thompson
Guest





PostPosted: Wed Jan 28, 2004 2:47 am    Post subject: Re: problem running an application from command line Reply with quote

"Andrew Thompson" ...
Quote:
"Joan" ...
| I have a .java file
....
java -cp . TheClass

Dang! Knew I had seen it somewhere..
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/classpath.html

If you put that command in a .bat file
in the same directory as TheClass,
the example should run when you
'double click' the bat file.

Now, for more explanation

[ java -classpath . TheClass ]

-classpath is the long form, -cp
only works for java and jdb

'.' add 'the current directory' to the classpath

TheClass - ..your class

HTH

--
Andrew Thompson
* http://www.PhySci.org/codes/ Web & IT help
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site



Back to top
Joan
Guest





PostPosted: Wed Jan 28, 2004 3:55 pm    Post subject: Re: problem running an application from command line Reply with quote

Chris Smith <cdsmith (AT) twu (DOT) net> wrote

Quote:
Joan wrote:
I have a .java file created using JCreator LE. I am able to compile
and run it from JCreator LE. But When I tried to do the same thing
from command line, I am able to compile it but got
"java.lang.NoClassDefFoundError" when I tried to run it (and it seems
that it doesn't matter which directory I am in).

Any idea why this is happening?

Where are your source files? What are your relevant environment
variables? What directory are you compiling from? (I know you said
you've tried several, but pick one that you think should work.) Where
is the J2SDK installed, and what version is it?

Thanks guys. Sorry I couldn't reply sooner. I waited the whole day
yesterday for my question to be posted. It must be some glitch within
Google.

I later on figured out that it is because I had a
"package myproject.myclassname" in the source file. That confused the
interpreter.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.