• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scanner  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I run this code from SCJP book

It throws this exception:

run:
java.lang.NoClassDefFoundError: scanset/Scanset
Caused by: java.lang.ClassNotFoundException: scanset.Scanset
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: scanset.Scanset. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)


In fact I do n't understand it uses args[0]!!without any initialize!!

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl hossein wrote:
I run this code from SCJP book

It throws this exception:

run:
java.lang.NoClassDefFoundError: scanset/Scanset
Caused by: java.lang.ClassNotFoundException: scanset.Scanset
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: scanset.Scanset. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)


In fact I do n't understand it uses args[0]!!without any initialize!!



It is complaining that it can't find the class scanset.Scanset. Do you have such a class?

Henry
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what on earth is that code supposed to do? Did you really find it in the SCJP book? The sort of things you read in some books
It might help you pass the exam, but I think code like that in real life would lose you your job
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And what on earth is that code supposed to do? Did you really find it in the SCJP book? The sort of things you read in some books
It might help you pass the exam, but I think code like that in real life would lose you your job


SCJP Sun certified programmer for java 6

page 505
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They do write some weird things in those exam preparation books. Look what somebody else said about exam questions:- here.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:They do write some weird things in those exam preparation books. Look what somebody else said about exam questions:- here.

I reckon they should rename it the SCHJC (Sun Certified Human Java Compiler) exam, because that's all it really tests; and some people are better at being one than others.

I suppose it might help in diagnosing surprising behaviour in obscure situations but, with a few notable exceptions (numeric promotion being one), I can't think of too much stuff I've actually used since I took it. I also wonder if it might not be better if, while teaching you about these exceptional cases, it also taught you how to avoid them.

Winston
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abalfazl,
Just remove this line:

and you are good to go.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the spelling error is different; he should have written scanset.ScanNext
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caused by: java.lang.ClassNotFoundException: scanset.Scanset


I think class name is ScanNext. so user should use scanset.ScanNext
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!