|
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Raven Illusion wrote:I checked my CLASSPATH and here is what is listed: ,;C:\Program Files\Java\jdk1.6.0_29\bin;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
Jeff Verdegan wrote:
You don't need CLASSPATH and shouldn't rely on it. If you specify -cp or -classpath on the command line, that will supersede whatever is in the CLASSPATH environment vraiable.
Additionally, that CLASSPATH looks suspicious. The first element, the comma (",") is not valid. Are you sure it's not a period (".")? (This will no matter if you use -cp or -classpath as suggested. Just pointing out something that looks odd.)
Did you try what I suggested in my previous post? If so, and it didn't work, please provide details.
Raven Illusion wrote:
I tried what you listed above and I get the same error message as in my original post.
Vyas Sanzgiri wrote:OR
you can use some of the beautiful free editors and focus on your code rather than
Try Netbeans IDE : www.netbeans.org
Jeff Verdegan wrote:
Vyas Sanzgiri wrote:OR
you can use some of the beautiful free editors and focus on your code rather than
Try Netbeans IDE : www.netbeans.org
I respectfully disagree. Understanding how classpath and packages work (along with the general concepts of absolute and relatives paths) is important for any Java developer. Certainly IDEs are useful as projects become bigger and more complex and the developer becomes more comfortable with the fundamentals, but by skipping to just doing everything in an IDE rather than overcoming this relatively minor obstacle, the OP would be doing a disservice to his education.
===Vyas Sanzgiri===
My Blog
Jeff Verdegan wrote:
This is getting a bit frustrating.
Please, in one post, indicate clearly exactly what you did (what directory you were in, what exact command you ran, where your .class file is, what the package declaration of your .java file is) and exactly what the result was (the exact, complete error message, copy/pasted).
When stuff is scattered across multiple posts, or not spelled out plainly and completely, it makes it very hard to build a mental picture that matches what you're seeing and doing when you're sitting at your computer.
Raven Illusion wrote:From a command line I go to C:\Documents and Settings\User\My Documents\Programming (this contains all of the class files I have created)
I run "java Weather" (sans quotes) when I hit enter I get error:
C:\Documents and Settings\User\My Documents\Programming>java Weather
Exception in thread "main" java.lang.NoClassDefFoundError: Weather
Caused by: java.lang.ClassNotFoundException: Weather
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Weather. Program will exit.
C:\Documents and Settings\User\My Documents\Programming>
what the package declaration of your .java file is: I do not know how to answer this question
Vyas Sanzgiri wrote:
Jeff Verdegan wrote:
Vyas Sanzgiri wrote:OR
you can use some of the beautiful free editors and focus on your code rather than
Try Netbeans IDE : www.netbeans.org
I respectfully disagree. Understanding how classpath and packages work (along with the general concepts of absolute and relatives paths) is important for any Java developer. Certainly IDEs are useful as projects become bigger and more complex and the developer becomes more comfortable with the fundamentals, but by skipping to just doing everything in an IDE rather than overcoming this relatively minor obstacle, the OP would be doing a disservice to his education.
I dont think this is the topic of conversation. It is to run the program.
With my experience, I only had to dig up on classpath and package for my SCJP. For everything else, including learning Java, Netbeans has worked wonders
Vyas Sanzgiri wrote:can you your complete Java code here ?
Raven Illusion wrote:thank you Jeff Verdegan
java -cp . Weather worked this time for some reason.
James Boswell wrote:Vyas
I believe the point Jeff is making is that an IDE can hide some of the fundamentals that every Java developer should know.
James Boswell wrote:Vyas
I believe the point Jeff is making is that an IDE can hide some of the fundamentals that every Java developer should know. Along with using the likes of Eclipse, NetBeans etc, it is crucial that a developer also understands the options available from the command line for the compiler and JVM.
===Vyas Sanzgiri===
My Blog
Straws are for suckers. Now suck on this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|