File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chapter 15 Head First - DailyAdviceClient and DailyAdviceService

 
Douglas Carvalho
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!! I just wrote both code of DailyAdvice program and compiled both without errors. But when I try to execute the server I got this:


Exception in thread "main" java.lang.NoClassDefFoundError: DailyAdviceServer/jav
a
Caused by: java.lang.ClassNotFoundException: DailyAdviceServer.java
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: DailyAdviceServer.java. Program will exit.


The same thing happen when I execute my DailyAdviceClient.class

The program works fine on netbeans though...but on prompt ....

The two codes are like this:



And:



What am i doing wrong???
 
Henry Wong
author
Marshal
Pie
Posts: 20828
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.NoClassDefFoundError: DailyAdviceServer/java
Caused by: java.lang.ClassNotFoundException: DailyAdviceServer.java
at java.net.URLClassLoader$1.run(Unknown Source)



It looks like you ran ....

java DailyAdviceServer.java

Instead of....

java DailyAdviceServer



Henry
 
Douglas Carvalho
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, that´s right!!! It just past midnight..... so I was using the arrows of keyboard so the command should turn this:

javac DailyAdviceServer.java

to this

java DailyAdviceServer

but I forgor to delete the .java ..... Thank you very much!! It worked fine now....

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic