It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

Problem running Java

Problem running Java

Postby stroodle01 on Fri Mar 23, 2007 9:32 pm

Hi there!

I am currently at university studying computing and at present learning how to program in Java. I am learning how to generate graphics using the 'Animax' console. I am using Textpad to edit, compile and run the code but its running the code that is proving to be impossible at the moment.

I have downloaded the latest JDK from the JAVA SUN website along with the Animax package. I have tried to compile a simple output program ("Hello World") which is syntacticly correct as it compile with no error message, but when i run the program the command line window consists of the message:

Exception in thread "main" java.lang.NoClassDefFoundError: Demo
Press any key to continue . . .


Insted of:
Hello World
Press any key to continue . . .


I would be very grateful if someone could help me to come up with a solution so i can proceed with my work.
Thanks, Stroodle :D
stroodle01
 
Posts: 10
Joined: Thu Mar 15, 2007 6:28 pm
Location: London, England

Postby AnthraX1 on Sat Mar 24, 2007 6:11 pm

I am still learning the basics, you probably know more lol but mind posting the code?
Looks to me you did not name your class.
AnthraX1
 
Posts: 12
Joined: Wed Mar 21, 2007 6:47 pm

Postby stroodle01 on Sat Mar 24, 2007 8:23 pm

Sure, the code is as follows:

class Demo001
{
public static void main(String[] args)
{
System.out.println("Blimey!!");
System.out.println("It Works!!");
}
}


The code is fine, the class path may be the problem. I have named the class correctly. I have a feeling a program may be interfering with the JAVA program path, which may involve messign arong with the registry settings (which i have no idea about!). Although saying this it has no problem compiling, the compiler JAVAC is located in the same folder as the JAVA program, although the program will still not run :? wich to me seems very wierd!!
stroodle01
 
Posts: 10
Joined: Thu Mar 15, 2007 6:28 pm
Location: London, England

Postby AnthraX1 on Sat Mar 24, 2007 9:06 pm

Try using netbeans, netbeans seems to get rid of all those errors and problems, I recommend netbeans unless your running a slow computer, give it a try in netbeans and tell me if it works. Also when you compile make sure the filename is Demo001 that can be causing the problem also.
AnthraX1
 
Posts: 12
Joined: Wed Mar 21, 2007 6:47 pm

Postby stroodle01 on Sun Mar 25, 2007 7:50 am

Thanx AnthraX1, i'll give it a blast!

I'll let you know how either way, Stroodle01
stroodle01
 
Posts: 10
Joined: Thu Mar 15, 2007 6:28 pm
Location: London, England

Postby a_bariar on Tue Apr 10, 2007 10:19 am

hey just place a modifier 'public' before the class name, this code will run.
note:- always define a class public in which u r redefining main() method. 8)
a_bariar
 
Posts: 2
Joined: Wed Mar 14, 2007 11:39 am


Who is online

Users browsing this forum: No registered users and 2 guests