GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Chapter 15 Head First - DailyAdviceClient and DailyAdviceService Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Chapter 15 Head First - DailyAdviceClient and DailyAdviceService" Watch "Chapter 15 Head First - DailyAdviceClient and DailyAdviceService" New topic
Author

Chapter 15 Head First - DailyAdviceClient and DailyAdviceService

Douglas Carvalho
Greenhorn

Joined: Oct 09, 2008
Posts: 4
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
Sheriff

Joined: Sep 28, 2004
Posts: 18874
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Douglas Carvalho
Greenhorn

Joined: Oct 09, 2008
Posts: 4
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....

 
GeeCON Prague 2014
 
subject: Chapter 15 Head First - DailyAdviceClient and DailyAdviceService