• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java App failed to run

 
Timothy Leong
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

I have the following code



I compile the program and create html coding. however my java app failed to run. It says "Loading java applet failed".

I even ran it as java Tutorial1

This is what I get.....
Exception in thread "main" java.lang.NoClassDefFoundError: Tutorial1

What can I do to make the program going? Thank you
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not an applet (it doesn't extend JApplet), so a browser wouldn't be able to start it from an HTML page.

On the command line, instead of "java Tutorial1", try to run it wirh "java -classpath . Tutorial1"
 
Timothy Leong
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Dittmer, thanks for your reply.

This is my classpath setting in Environment Variables.

C:\Program Files\Java\jdk1.5.0_02\lib\tools.jar

normally how does classpath directory looks like?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point, you should NOT use the CLASSPATH variable at all. If you remove the CLASSPATH variable, it should fix your problem.

Layne
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
 
Ken MacClune
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Similar problem here. I compile my FirstApp and get the error (Exception in thread "main" java.lang.NoClassDefFoundError) when attmpting to run in the command window. ? Using or not using -classpath seems not to matter.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken MacClune:
Similar problem here. I compile my FirstApp and get the error (Exception in thread "main" java.lang.NoClassDefFoundError) when attmpting to run in the command window. ? Using or not using -classpath seems not to matter.


Ken,

Please start your own thread and include the following details:

  • The full path to the directory where your .java file is saved
  • Which directory your command prompt is at before you try to compile
  • What you type at the command-line to compile your program


  • From there we will be able to help you correct the problems you have encountered.

    Layne
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic