Advertisement

10.22.2004 at 02:34PM PDT, ID: 21179400
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Exception in thread "main" java.lang.NoClassDefFoundError - Java2sdk1.4.2_06

Tags: thread, exception
I've obviously a newbie to java, *ATTEMPTING* to teach myself, but I've run into a problem that's really held me up.

As you can see below, I'm attempting to run a java application called "helloworldapp".  helloworldapp.class (and .java) is located in c:\j2sdk1.4.2_06\bin\helloworldapp.
It compiles just fine but will not run.  I think there may be a classpath problem, but I've changed the path a ton of times and can't get it right.

_________________________________

C:\j2sdk1.4.2_06\bin\HelloWorldApp>javac helloworldapp.java

C:\j2sdk1.4.2_06\bin\HelloWorldApp>java helloworldapp
Exception in thread "main" java.lang.NoClassDefFoundError: helloworldapp (wrong
name: HelloWorldApp)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        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)

C:\j2sdk1.4.2_06\bin\HelloWorldApp>dir
 Volume in drive C has no label.
 Volume Serial Number is 549D-DF6C

 Directory of C:\j2sdk1.4.2_06\bin\HelloWorldApp

10/22/2004  03:46 PM    <DIR>          .
10/22/2004  03:46 PM    <DIR>          ..
10/22/2004  04:17 PM               432 HelloWorldApp.class
10/22/2004  03:59 PM               157 HelloWorldApp.java
               2 File(s)            589 bytes
               2 Dir(s)   3,418,599,424 bytes free
_____________________________________

Running WinXP SP2, and here's what I have for my environmental variables:

User variables:
CLASSPATH - .;C:\j2sdk1.4.2_06\bin
PATH - .;C:\j2sdk1.4.2_06\bin

System variables:
CLASSPATH - .;C:\j2sdk1.4.2_06\lib\tools.jar;C:\j2sdk1.4.2_06\jre\lib\rt.jar;C:\j2sdk1.4.2_06\jre\classes
JAVA_HOME - c:\j2sdk1.4.2_06
Path - %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\NMapWin\\bin;"C:\Program Files\Symantec\Norton Ghost 2003\";C:\j2sdk1.4.2_06\bin;JAVA_HOME;

I found many instances of this issue here and elsewhere and have tried most of their suggestions, and now I'm afraid I may have just completely messed it all up!

Please help!
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: tebacher
Solution Provided By: CEHJ
Participating Experts: 11
Solution Grade: A
Views: 415
Translate:
Loading Advertisement...
10.22.2004 at 02:35PM PDT, ID: 12385398

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 02:40PM PDT, ID: 12385428

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 02:42PM PDT, ID: 12385438

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 02:44PM PDT, ID: 12385461

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 03:08PM PDT, ID: 12385600

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 03:25PM PDT, ID: 12385702

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:25PM PDT, ID: 12386023

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:29PM PDT, ID: 12386042

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:35PM PDT, ID: 12386070

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:41PM PDT, ID: 12386097

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:43PM PDT, ID: 12386110

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:45PM PDT, ID: 12386120

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.22.2004 at 04:53PM PDT, ID: 12386145

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.23.2004 at 06:23AM PDT, ID: 12387988

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.23.2004 at 06:28AM PDT, ID: 12388009

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.23.2004 at 06:31AM PDT, ID: 12388016

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.23.2004 at 06:32AM PDT, ID: 12388021

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.23.2004 at 06:33AM PDT, ID: 12388022

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.23.2004 at 06:55PM PDT, ID: 12390976

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 06:31AM PDT, ID: 12399946

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 07:20AM PDT, ID: 12400412

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.12.2004 at 12:11AM PST, ID: 12563294

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.16.2005 at 04:51AM PST, ID: 13323097

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
10.22.2004 at 02:35PM PDT, ID: 12385398

Rank: Genius

Try

java -classpath . helloworldapp
 
10.22.2004 at 02:40PM PDT, ID: 12385428

Rank: Genius

Java of course is case-sensitive, so the class name must be exactly as declared in the class file, and the same as the file name
Accepted Solution
 
10.22.2004 at 02:42PM PDT, ID: 12385438
As the exception suggests - you have a problem with names.
Try renaming the helloworldapp.java file to HelloWorldApp.java and running "java HelloWorldApp" .
 
10.22.2004 at 02:44PM PDT, ID: 12385461

Rank: Master

are you running your command from this path
C:\j2sdk1.4.2_06\bin\HelloWorldApp>java helloworldapp

check if your helloworldapp.java has got any package?? if it has any package you need to create the folders as in the package names in your java files and then place the class file in the last folder of your package. Then you can run ur app like

C:\j2sdk1.4.2_06\bin\HelloWorldApp>java com.helloworldapp.helloworldapp


the folder from where u run the command should also have the package starting  for your java class.
 so like in the above command if your package is com.helloworldapp then u should be having folders
C:\j2sdk1.4.2_06\bin\HelloWorldApp>
---------------->com------->helloworldapp

pl check out all these and test again.
hope this helps

 
10.22.2004 at 03:08PM PDT, ID: 12385600
See CEHJ's comment, if still no luck, try this:
just add this line, and press enter, before running (and preferably prior to compiling) your file:

set classpath=%classpath%;%cd%

Best of luck,
[r.D]
 
10.22.2004 at 03:25PM PDT, ID: 12385702
Heres what your problem is...
 as suggested by CEHJ you are using wrong class name

You are using java helloworldapp

while the contents of the directory say its HelloWorldApp.class

so You should be using java HelloWorldApp

Here is a simple scenario that I tried without looking much into the problem and it even sounds the same....

Your file name is helloworldapp.java

class HelloWorldApp
{
public static void main(String[] args)
{
System.out.println("Hello");
}
}

It compiles and when U look at the contents of the directory U will get
helloworldapp.java
HelloWorldApp.class
Now try this in same file removing the above contents

public class helloworldapp
{
public static void main(String[] args)
{
System.out.println("Hello");
}
}

It compiles as the public class name and file name are same but If You look at contents of directory You should get
helloworldapp.java
helloworldapp.class

but surprisigly I found HelloWorldApp.class instead of helloworldapp.class( I donno why this is happening)

but to execute it I need to give java helloworldapp

If I give java HelloWorldApp I get the following error

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp (wrong
name: helloworldapp)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:605)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        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:290)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:279)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:236)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:303)

Which is exactly the error shown above......

So open HelloWorldApp.java

check the class name that contains main...

and then use that classname after java while trying to run.
 
10.22.2004 at 04:25PM PDT, ID: 12386023

Rank: Genius

run it using the following:

java HelloWorldApp

(your classpath is fine, and everything else appears fine)
 
10.22.2004 at 04:29PM PDT, ID: 12386042

Rank: Genius

That's already been said (several times)
 
10.22.2004 at 04:35PM PDT, ID: 12386070

Rank: Genius

Not directly (in fact only Ori did actually), and the above comments primarily talk about changing the classpath and filename which are all unnecessary.
 
10.22.2004 at 04:41PM PDT, ID: 12386097

Rank: Genius

However reliable the evidence of the classpath that's *actually being used is* (and that shouldn't be assumed to be 100% correct) all the information necessary to get this working has already been given
 
10.22.2004 at 04:43PM PDT, ID: 12386110
Not to mention that it is not necessary to have the environment variable classpath set. I had a similar problem when I started coding in java, and fixed it by deleting the classpath env variable

 
10.22.2004 at 04:45PM PDT, ID: 12386120

Rank: Genius

So what exactly is your problem, with my clarifying what I believe to be the correct approach to run the command? As well as useful information, there is also a lot of erroneous information posted which could well confuse the asker. For eaxample, the suggestion that you posted will certainly *not* work.

 
10.22.2004 at 04:53PM PDT, ID: 12386145

Rank: Genius

>>So what exactly is your problem, with my clarifying what I believe to be the correct approach

Simply that it's unnecessary. Your comments simply repeat what Ori Kremer said, which was the specific form of my more generic second comment
 
10.23.2004 at 06:23AM PDT, ID: 12387988

Rank: Sage

CEHJ & objects, don't fight! It's becoming a habit!

;JOOP!
 
10.23.2004 at 06:28AM PDT, ID: 12388009
lol - last time I had a disagreement with someone, I was threatened that I will loose my account for it! :o\

 
10.23.2004 at 06:31AM PDT, ID: 12388016

Rank: Sage

By whom? Only moderators may tell you so.
;JOOP!
 
10.23.2004 at 06:32AM PDT, ID: 12388021

Rank: Sage

tebacher, next time you have such a problem, post your source;
it would have made this all easier and shorter.
;JOOP!
 
10.23.2004 at 06:33AM PDT, ID: 12388022
Yup -- it was moderators!
 
10.23.2004 at 06:55PM PDT, ID: 12390976

Rank: Guru

By the way, putting your java app in "C:\j2sdk1.4.2_06\bin" is not a good idea.
Using a directory of your own is much better (something like "C:\MyJavaProjects\HelloWorld").
 
10.25.2004 at 06:31AM PDT, ID: 12399946
Wow, lots of help in this TA!  Thanks to everyone who has helped so far.

I *swear* I tried 'java HelloWorldApp' (with Caps as they should be) before I posted here!  But, after the weekend I booted up my PC and tried it with the caps, and it worked.   Just a case problem  :-)
Maybe I tried the Caps BEFORE I got the correct class path in and then just disregarded it from then on.

Anyway, thanks for the help!
 
10.25.2004 at 07:20AM PDT, ID: 12400412

Rank: Genius

8-)
 
11.12.2004 at 12:11AM PST, ID: 12563294
Aside from all the others' comments,

I suggest you to use an IDE for java..

some popular ones includes the paid ones such as borland, or JCreator Pro.

while the free ones such as Gel.

the IDE helps you a lot when it comes to memorization of different java packages and therefore allows you to easily learn Java.
 
02.16.2005 at 04:51AM PST, ID: 13323097
> Aside from all the others' comments,
> I suggest you to use an IDE for java..
> some popular ones includes the paid ones such as borland, or JCreator Pro.
> while the free ones such as Gel.

You must be kidding!?! Don't even think of looking further than the Eclipse IDE!
 
 
20080236-EE-VQP-29