Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run Time error

 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have compiled my program into bytecode, and am having difficulty running the jvm. when i tried to run it i got the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: Party
Caused by: java.lang.ClassNotFoundException: Party

Any help would be great...thanks!
 
Henry Wong
author
Marshal
Pie
Posts: 21127
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can't find the class -- which could mean that your classpath isn't set correctly, or you put the class file in the wrong location.

Henry
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class file is located here:

C:\Users\Jeff\Documents

My class path is set to:

C:\Users\Jeff\Documents\Java\jdk1.6.0_14\bin

 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this command

java -cp C:\Users\Jeff\Documents party


it should work
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still no luck
 
Henry Wong
author
Marshal
Pie
Posts: 21127
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:The class file is located here:

C:\Users\Jeff\Documents

My class path is set to:

C:\Users\Jeff\Documents\Java\jdk1.6.0_14\bin



First, there is a distinction between PATH and CLASSPATH. You need to tell us what was set and to what.

Second, the classpath is for the root of the classes. You also need to tell us if your classes are in packages.

And of course, you need to tell us exactly what is being executed -- the exact command line.

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12127
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:The class file is located here:

C:\Users\Jeff\Documents

My class path is set to:

C:\Users\Jeff\Documents\Java\jdk1.6.0_14\bin


Note: There is no such thing as a "class path". you should have a "classpath" variable, a "path" variable, or possibly both... but "class path" is meaningless.

 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a CLASSPATH as well as a path and both variables are set to the following:

C:\Users\Jeff\Documents\Java\jdk1.6.0_14\bin
 
Henry Wong
author
Marshal
Pie
Posts: 21127
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:i have a CLASSPATH as well as a path and both variables are set to the following:

C:\Users\Jeff\Documents\Java\jdk1.6.0_14\bin


That is the problem. CLASSPATH is for classes, not for the jvm and compiler. Unset it.

[edit: accidentally reverse PATH and CLASSPATH... fixed]

Henry
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i unset it, but it still gives me the same error
 
Henry Wong
author
Marshal
Pie
Posts: 21127
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:i unset it, but it still gives me the same error


See my previous post, you need to tell us a bunch of other stuff, or we can't tell you what's wrong.

Henry
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@henry,, no we can append our own path in the classpath variable for extra classes we have...
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please show the code??
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PATH is set to

C:\Users\Jeff\Documents\Java\jdk1.6.0_14\bin

I'm not sure if my classes are in packages, how could I tell this?

My command line looks like this:

C:\Users\Jeff\Documents> java Party

(The class file is Party.class, saved in C:\Users\Jeff\Documents)
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look into the source file and tell if there is a package statement ?? if yes then remove that...have you coded this java file on your own??
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried 2 different programs:
ExampleProgram

//A Very Simple Example
class ExampleProgram {
public static void main(String[] args){
System.out.println("I'm a Simple Program");
}
}

as well as
Party

import java.awt.*;

import java.awt.event.*;

class Party {

public void buildinvite() {
Frame f = new Frame();
Label l = new Label("Party at Tim's");
Button b = new Button("You bet");
Button c = new Button("Shoot me");
Panel p = new Panel();
p.add(l);
} // more code here...
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
type this command java ExampleProgram , the name of class in which you have main function......
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose you are having main method in a class named class2 then the command should be

java class2
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ExampleProgram ran...thanks for all of your help!
Party still won't but I may have a code error in there...
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are welcome dude!!
 
fred rosenberger
lowercase baba
Bartender
Posts: 12127
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:The ExampleProgram ran...thanks for all of your help!
Party still won't but I may have a code error in there...

If you have a code error, then either it won't compile, or something bad would happen when you ran it. a code error wouldn't stop the program from running.

Make sure you have a file called Party.class

cd to the directory where it is.

run this:

java Party

and tell us what happens.
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried, still got the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Party : Unsupported major.minor version 8242.8224
 
Henry Wong
author
Marshal
Pie
Posts: 21127
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:I tried, still got the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Party : Unsupported major.minor version 8242.8224


Can you tell us what version of the compiler you are using? Or if you are using any special class loaders? I have never seen those major and minor numbers before.

Henry
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the JavaFX1.2 SDK
 
Campbell Ritchie
Sheriff
Pie
Posts: 48984
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not the J2SE Version? Write javac -version and java -version at the command line and see whether you get anything beginning with 1.6.0. You can download the ordinary JDK here.
 
abhishek kunal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to reinstall the normal jdk...not javafx one....install jdk1.6...problem is of version mismatch...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Te wrote:I tried, still got the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Party : Unsupported major.minor version 8242.8224

This looks really strange. Normally this error means that you are trying to run a class compiled with a newer JDK on an older JRE. But this looks different, because the version number in the error message is very strange "8242.8224".

It looks like the class file is corrupted. Did you maybe save your source code with the extension ".class" instead of ".java", or did you do anything else that could have corrupted the class file?

Delete the class file, compile your source code and try to run it again.
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saved the source file as .java before I compiled it. Would removing my Java completely and reinstalling it be a good idea?
 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ciao , can you please tell em , which version java you used to compile the your java class and which version of java you used to run the java class ?
 
Jeff Te
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded the JavaFX SDK...here is the link:

http://java.sun.com/javafx/1/reference/sdk-install/install-javafx-sdk-1-2.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic