• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

I get this when I try to launch my application...

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.NoClassDefFoundError: UBBSmiley (wrong name
: ubbsmiley/UBBSmiley)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:11
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
I'm running Windows 2000... I'm just typing "java UBBSmiley" in the same folder as my .class files. Any ideas?
EDIT: I made it in JBuilder and it executes fine there.
[This message has been edited by Steve B (edited August 26, 2001).]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your class path include the current directory?
Try java -cp . UBBSmiley
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it looks like you've got a hint in the error trace.

It has "wrong name: ubbsmiley/UBBSmiley"

I haven't compiled any test cases, so I forget which of the following two causes is the exactly right answer:

1. Your UBBSmiley class is in the ubbsmiley Package, but you do not have that class in a folder structure that reflects that.
2. Your UBBSmiley class isn't packaged, but you are running it as if it were.

I think it's that first one.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that your capitalization on the class name in the file is the same as the file name capitalization and that you are invoking it with that capitalization. The operating system will ignore the capitalization errors, but java won't.
 
Steve B
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Mike Curwen:
it looks like you've got a hint in the error trace.

It has "wrong name: ubbsmiley/UBBSmiley"

I haven't compiled any test cases, so I forget which of the following two causes is the exactly right answer:

1. Your UBBSmiley class is in the ubbsmiley Package, but you do not have that class in a folder structure that reflects that.
2. Your UBBSmiley class isn't packaged, but you are running it as if it were.

I think it's that first one.


could you explain a little about packaging to me?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure,
Basically, I've duplicated your error with this:This compiles fine, and my class files are here:
d:\javawork\javaranchTest\UBBSmiley.class
Then I invoke java on this class, from the javaranchTest folder:
d:\javawork\javaranchTest> java UBBSmiley and I get this:The reason I get the "wrongname: ubbsmiley/UBBSmiley" error, is that the compiler *finds* a class file named UBBSmiley, but it is the wrong one, because that classfile contains some packaging information.. namely that the classfile 'ought to be found inside a folder named ubbsmiley.

When you are packaging your java source files, remember that the class files must be found within folders of the same name. Where your class files are located on your filesystem must reflect the packaging instructions of the java source file.

So simply moving my classfile to:
d:\javawork\javaranchTest\ubbsmiley\UBBSmiley.class
and running java from:
d:\javawork\javaranchTest> java ubbsmiley.UBBSmiley
produces the expected "Hello World!"

Note also, that I had to include the fully qualified classname for the java runtime. (package.class -> ubbsmiley.UBBSmiley)
 
Steve B
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks man!! I got it going! you rock!
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic