Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error in JBuilder

Status
Not open for further replies.

coolskater49

Technical User
Nov 20, 2002
20
GB
hiya,

im writing a pretty simple application in Java using JBuilder 9.
i have 2 .java files in my project, one of which holds a class containing methods i have defined myself, the other holds a class containing a main() method. Within the main() method the user is prompted to enter data, and actions are performed on this data using the methods in the other class.

example of class containing methods:-

public class MyMaths
{
public static int sum(int a, int b)
{
return (a + b);
}

example of class containing main() method:-

import corejava.*;
import MyMaths.*;
public class SimpleMaths
{
public static void main(String args[])
{

When i come to run this project i get the error -
"SimpleMaths.java": package MyMaths does not exist at line 2, column 1

If i then remove the line 'import MyMaths.*;' i get no compiler errors but when i run, a Java Virtual Machine Launcher dialog box appears saying 'Could not find main method. Program will exit!'
the following message is also displayed 'java.lang.NoSuchMethodError: main'

Can anyone please help?
this is probably something simple i have missed out but i cant see anything wrong

thanks in advance

Paul.
 
>>>>> "SimpleMaths.java": package MyMaths does not exist at line 2, column 1

In your class "SimpleMaths", you try to import a package called "MyMaths" - but this is a class, not a package - hence the message "package MyMaths does not exist".

>>>>> Launcher dialog box appears saying 'Could not find main method. Program will exit!'

To be executed from the command line (which is effect what you are doing via JBuilder), method within the class you are trying to interpret must contain the method signature
Code:
 public static void main(String args[]) {}
.


PS, IMHO, these are fairly basic errors, and I think using an IDE like JBuilder is really not the best option when you are starting out, because you don't learn the basic syntax very well. Try doing these simple learning programs using vi or notepad/textpad - you will learn a lot more about compilation and debugging.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top