Ok, so I just started to learn Java, and I picked up the book Head First. I wrote the intro source code which is called "Party.java" in a program called Jedit, which I downloaded. I then went to the javac terminal and went to the command tab and entered "javac Party.java". It is telling me that error: cannot read: Party.java 1 error. Do I have the java file in the wrong directory or something?
ok I just rewrote it and it was fixed... now I have hello.class file in my folder. I tryed running java hello and Exception in thread "main" java.lang.NoClassDefFoundError: hello [Process exited - exit code 1] comes up... ??
Its a error caused when you do not set your CLASSPATH properly.while you use java command try directing your command to the correct location of your class
eg:
suppose your hello.class exists in X:\firstPrg\Hello.class and you are running your program from d:\ in the command prompt then
you should use java -cp X:\firstPrg Hello this would work.....
Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file)
where options include: -client to select the "client" VM -server to select the "server" VM -jvm is a synonym for the "client" VM [deprecated] -hotspot is a synonym for the "client" VM [deprecated] The default VM is client.
-cp <class search path of directories and zip/jar files> -classpath <class search path of directories and zip/jar files> A : separated list of directories, JAR archives, and ZIP archives to search for class files. -D<name>=<value> set a system property -verbose[:class|gc|jni] enable verbose output -version print product version and exit -version:<value> require the specified version to run -showversion print product version and continue -jre-restrict-search | -jre-no-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:<libname>[=<options>] load native agent library <libname>, e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:<pathname>[=<options>] load native agent library by full pathname -javaagent:<jarpath>[=<options>] load Java programming language agent, see java.lang.instrument [Process exited - exit code 1]
I think you're getting great help here, but I suspect that there's another problem too. Our bad! We didn't really want our readers to try to compile the class we show on page 3. We put a note at the bottom of the page indicating that, but you're not the first to miss that, so we're going to fix that page.
In the meantime, if you skip ahead to page 9, you can go ahead and type that class in, then let these guys help you out with whatever environment setup issues you have to work out. When you do type that class in, it'll also help to copy and paste that code into your question.
Any finally, hang in there! The setup issues you're dealing with are probably the hardest thing you'll have to do for the next couple hundred pages
Wow, a first for me. I'm in a forum where you can actually interact w/ an author of a book that you're reading. This is truly mind-blowing! I'm delving into Head First Design Patterns, one of the most amazing books on programming that I've studied yet, and one that is opening up my eyes to true code reuse. Thanks, Bert Bates.