Trying to create a java application?

2 replies [Last post]
Offline
Last seen: 1 year 24 weeks ago
Joined: 10/07/2010
Posts:

import java.lang.*;

public class Program{

public Program(){

}

public static void main(String args[]) {

System.out.println("Hello World from Compilr!");
System.out.println("Press any key to continue.");

}
}

What's wrong with this code, I can't get it to run. The error I get is :

"Could not find the main class. Program will exit."

I thought that I needed to put my public static void main method in a class called Project??

magius96's picture
Offline
Last seen: 14 weeks 1 day ago
Joined: 04/13/2009
Posts:
Just my guess

I'm not an expert on Java, nor do I even work with it, but here's my guess. Call it a shot in the dark.

You added a Constructor to the program class, yet you did not instantiate the program class inside the main block. Also, when creating a web app with Java, the default project has the default class extending some Java class. I'm not sure if that needs to be done with a console app or not, but it's worth a try.

----------------------------------------------------------------------------------------------------
"Coding your life, Compiling your dreams, and crashing your future."
Compilr - C# and VB.NET Advisor

tim.speed's picture
Offline
Last seen: 18 hours 6 min ago
Joined: 02/24/2010
Posts:
Click the settings button

Click the settings button from the top bar in the IDE, and edit your main class to be "Program" without the quotes. The file containing the Program class should also be named Program.java

-----------------
Tim Speed
Compilr Developer and CTO