Sign in to follow this  
GekkoCube

[java] i can compile JAVA, but cant run CLASSes!

Recommended Posts

i can compile java files and it generates class files. but i cant run the classes. c:\java_file_location\java HelloWorld ----------- i reinstalled this JRE last night, jre-1_5_0_06-windows-i586-p-iftw. when i try to run i get this error: 'Exception in thread "main" java.lang.NoClassDefFoundError: HelloJava1' ...and yes, this class does exist.

Share this post


Link to post
Share on other sites
Quote:
Original post by GekkoCube
c:\java_file_location\java HelloWorld
NoClassDefFoundError: HelloJava1'

A class called "HelloJava1" should be in a file called "HelloJava1.class".
A class called "HelloWorld" should be in a file called "HelloWorld.class".

You have seem to have intermixed class name and file name.

Is your class public? And does it have a public static main method?

Share this post


Link to post
Share on other sites
here's a thought...

if i install the java SDK, in my case jdk1.5.0_06, do i need to install the jre (java runtime), which in my case i have jre1.5.0_06 ?

maybe this has somethign to do with it, although i cant see why this is the problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by GekkoCube
if i install the java SDK, in my case jdk1.5.0_06, do i need to install the jre (java runtime), which in my case i have jre1.5.0_06 ?

The SDK includes the JRE. There should be a JRE folder in the SDK folder.

Of course you cannot run .class files built by Java 1.5 with Java 1.4

Share this post


Link to post
Share on other sites
okay, i've no idea.

i know the -cp is for classpath.
but i never had to do this before.

and besides, the class exists in the same folder as the call to java.
so what gives?
also, when i exit the java app, the console gets stuck!

Share this post


Link to post
Share on other sites
I finally found the problem!

In my environment variables, my classpath had something on there for quicktime. i deleted that and everything works fine, ie. "c:\java helloworld" rather than "c:\java -cp . helloworld"


here's where i found the helpful post.
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=012677

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this