This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help me to set the path

 
monica mitra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have WINDOWS XP at my system.I set the path in this way.From start manu i entered in to Control Panel then to Performane & Maintenance then I clicked on System & then Advanced & then Environment Variables.Then in side System Varibles i wrote the following line in to "path" starting from it's right end
"c:\program files\java\jdk1.5.0_<version>\bin".
have i done make some mistake?Please correct me.Waiting for reply .
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by monica mitra:
...i wrote the following line in to "path" starting from it's right end
"c:\program files\java\jdk1.5.0_<version>\bin".
have i done make some mistake? ...

Where the example says <version> you need to substitute whatever version you're using (that is, the actual name of the directory). For example, if you have update 7, the path would be...

c:\program files\java\jdk1.5.0_07\bin

See these installation instructions for more details.
 
monica mitra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can now compile the program. but when I try to run the program by typing java classname say java Add .It throws me an exception message "Exception in thread "main" java.lang.NoClassDefFoundError:Add".
why am i getting this message ?what should I do?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49745
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Exception in thread "main" java.lang.NoClassDefFoundError:Add".
You can find out about run time error messages here. That message means one of many things described on that website, most of which are unlikely in this instance.

The most likely explanations are that you haven't actually compiled the Add class (use the dir command on command prompt to find the Add.class file) OR that the Add class doesn't have a public static void main(String[] args) method in. Remember that is the bit the JVM is looking for; if it doesn't find it, the NoClassDefFoundError is how it responds.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, if you've compiled successfully, then you should have a .class file in the directory. Have you verified that Add.class exists?

Second, when you enter java Add on the command line, your working directory should probably be the directory that contains the Add.class file. (This is not always the case. But I'm making an assumption because it appears this is one of your first programs after getting the Java compiler installed.) You change directories by typing cd followed by a space and then the path of the desired directory.

Third, I'm also hoping that you have not set a system CLASSPATH variable (which is different than a PATH variable). If you have set a system CLASSPATH without knowing exactly why, then I suggest you remove it completely. If you have set a system CLASSPATH and you really do need to keep it, then make sure it includes a dot (.) to indicate the current directory.
[ June 17, 2006: Message edited by: marc weber ]
 
monica mitra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can successfully compile and run the program.Thanks for help.
I'm planning to take scjp5.0.What should I do to score good percentage?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by monica mitra:
... I'm planning to take scjp5.0. What should I do to score good percentage?

That's great! Here is our SCJP FAQ from our SCJP forum. That should help you get started.

Basically, I recommend that you...
  • Learn the Java basics first, without concentrating on the SCJP objectives. Use a good book, like Head First Java.
  • As you're learning, write lots of test code to reinforce the concepts.
  • After you have a foundation, then start to focus on the SCJP objectives. Again, a good book that's specifically geared to the desired exam version is essential.
  • As you're preparing, write lots of test code to test your understanding.
  • As you get closer to taking the exam, take as many mock exams as possible to get familiar with the types of questions and find out where you need to spend more time studying.
  • (You'll notice that I listed "write lots of test code" twice.)

    PS: What was the problem running the program? Did you have a CLASSPATH set?
     
    bama sabapathi
    Greenhorn
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I have Windows Xp Home Edition in my Home Computer.I installed Java 1.5 in C:\Program Files\Java\Jdk1.5.0_06 path.I am trying to execute example.java in C:\Java path.it is giving "javac" is not recoginsed as an internal or external command,operable pragram or batch file" comes each time when i try to compile the program.

    Please help me to solve this Problem.
    Thanks,
    Bama
     
    Campbell Ritchie
    Sheriff
    Pie
    Posts: 49745
    69
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bama Sabapathi: Go to Marc Weber's first post in this thread, and follow the installation instructions quoted, to the letter. A single spellign mistake and nothing will work.
     
    marc weber
    Sheriff
    Posts: 11343
    Java Mac Safari
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Campbell Ritchie:
    ...and follow the installation instructions quoted, to the letter...

    Especially Step 5.
     
    bama sabapathi
    Greenhorn
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thank you marc.I am finally sucessfully running JDK1.5.
    Thanks,
    Bama.
     
    Don't get me started about those stupid light bulbs.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic