aspose file tools*
The moose likes Beginning Java and the fly likes Classpath question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Classpath question" Watch "Classpath question" New topic
Author

Classpath question

Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
Hi,

I've written the following program and have compiled and got the class file in "C:/jdk1.5/bin/myproject/classes/a/first/" directory and now when I'm trying to run this program its giving "java.lang.NoClassDefFound" . Plz tell what should I do.

I've stored the .java file in "myproject/a/first" directory in bin folder.


Thanks


SCJP 1.5
Daniel Bryant
Ranch Hand

Joined: Jul 15, 2006
Posts: 54
Hi Asha,

First off, it's probably best not to store your Java project files in the java/bin directory as it can get pretty full, and also you won't get to experience the full fun of classpaths unless you deploy code outside of you Java directory

In answer to your question - are you compiling in the correct directory? (in your post I noticed that you stated two different locations in which your temp1.java file was)

If your temp1.java file is the C:/jdk1.5/bin/myproject/classes/a/first/ I would make sure you are located in the C:/jdk1.5/bin/myproject/classes folder and then try executing

Best wishes,

Daniel


SCJP 1.4,<br />SCJD (URLyBird 1.2.1, JDK 5.0)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
As this is a common beginner's question I'm moving this to Java in General (Beginner).


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
Hi Daniel,

I don't have any problem in compiling the program. After compiling I'm getting my ".class" file in "C:/jdk1.5/bin/myproject/classes/a/first" folder. But I'm not able to execute this file.

Plz help,
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Please don't repost the same question in another forum, even if an ungodly time period like two hours has passed without your getting an answer that is satisfactory to you. Perhaps the fact that it is Saturday has something to do with it. I've deleted your duplicate post.

Perhaps you haven't gotten additional answers because Daniel has already done an excellent job of responding to your question, but for some reason that's unclear to me, you've chosen not to respond to his counter-questions. Answer them, and he (or someone else) is likely to continue to help you understand this material. We can't explain to you what you are misunderstanding until we can figure out what you're thinking right now. While you're at it, you might show us what actual command line you used, so we can tell you how to modify it.


[Jess in Action][AskingGoodQuestions]
Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
Hi Ernest,

I'm really sorry if my reposting the same question in another forum offended you. I'll wait for the answers but I've already scheduled my exam on 19th of this month and I'm doing really bad in classpaths question thats why got little panicky which happens to everyone if they'll have the exam so close.

Thanks
Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
Hi,

For compiling I'm giving the following command at "C:\jdk1.5\bin>" prompt:

javac -d myproject/classes myproject/a/first/temp1.java

for executing I'm gining the following command at the same prompt:

java -classpath myproject\classes temp1

Thanks
Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
In the second command I've by mistake typed the "backslash" instead of "forward slash".
Asha Pathik
Ranch Hand

Joined: Feb 08, 2006
Posts: 143
Hi everybody,

I got the answer after a lot of hit&trial. Thanks for all the help.

Asha
CJ Thorno
Greenhorn

Joined: Jun 19, 2006
Posts: 3
What was the problem?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Classpath question