5 Replies - 832 Views - Last Post: 11 September 2008 - 02:17 PM Rate Topic: -----

#1 alexgio   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 26-March 08

Simple Program

Post icon  Posted 10 September 2008 - 07:27 PM

public class WhatsGood

{
	public static void main (String[ ] args)
	{
		System.out.println ("Whats goin on?");
	}

}
		   


I am taking my first class on Java programming. Unfortunately my professor is of little help as he does not have much time to work with students. We are supposed to write this code then compile it. (which works fine) and then we are supposed to run it. When I try to run this program here is what comes up on my Command Prompt window.

C:\Documents and Settings\Alex (geo)\Desktop>java WhatsGood
Exception in thread "main" java.lang.NoClassDefFoundError: WhatsGood
Caused by: java.lang.ClassNotFoundException: WhatsGood
		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:\Documents and Settings\Alex (geo)\Desktop>javac WhatsGood.java



Any help would be greatly appreciated....

Thanks So much

Is This A Good Question/Topic? 0
  • +

Replies To: Simple Program

#2 skin__   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 20-May 08

Re: Simple Program

Posted 10 September 2008 - 07:33 PM

You need a main method.
Was This Post Helpful? 0
  • +
  • -

#3 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Simple Program

Posted 10 September 2008 - 07:33 PM

It is the other way around

1) compile program
javac WhatsGood.java
2) run it
java WhatsGood
Was This Post Helpful? 0
  • +
  • -

#4 DaneAU   User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,620
  • Joined: 15-May 08

Re: Simple Program

Posted 11 September 2008 - 06:27 AM

View Postpbl, on 10 Sep, 2008 - 07:33 PM, said:

It is the other way around

1) compile program
javac WhatsGood.java
2) run it
java WhatsGood


Make sure your .java is saved the same as you're class name.

WhatsGood


Is what you chose to call you're class so save your .java as WhatsGood.java and follow pbl's post above ;)
Was This Post Helpful? 0
  • +
  • -

#5 alexgio   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 26-March 08

Re: Simple Program

Posted 11 September 2008 - 01:22 PM

Success!!!!

Thank you All so much. I love this Site I always find out what I need.

Sincerely

Gio
Was This Post Helpful? 0
  • +
  • -

#6 C++ Programmer   User is offline

  • D.I.C Addict
  • member icon

Reputation: 20
  • View blog
  • Posts: 548
  • Joined: 12-June 08

Re: Simple Program

Posted 11 September 2008 - 02:17 PM

Another person that found out what the need on D.I.C! Love this site!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1