Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classpath question

 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Daniel Bryant
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As this is a common beginner's question I'm moving this to Java in General (Beginner).
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the second command I've by mistake typed the "backslash" instead of "forward slash".
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

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

Asha
 
CJ Thorno
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What was the problem?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic