Can't run java applications!

O

ohaya

Hi,

It's been awhile since I've tried to run any Java applications on this
one machine, but when I tried tonight, I am getting some really strange
problems.

Here's a small application (test.java):

public class test {
public static void main () {
}
}

This compiles ok, but when I run it ("java test"), I am getting:

"Exception in thread "main" java.lang.NoSuchMethodError: main"


Maybe it's been too long a day, but I've been staring at this for
awhile, and I hope that maybe someone can tell me what is wrong :(.

Thanks,
Jim
 
J

JScoobyCed

ohaya said:
Hi,

It's been awhile since I've tried to run any Java applications on this
one machine, but when I tried tonight, I am getting some really strange
problems.

Here's a small application (test.java):

public class test {
public static void main () {
}
}

This compiles ok, but when I run it ("java test"), I am getting:

"Exception in thread "main" java.lang.NoSuchMethodError: main"

Yes, I guess it's been a long day.
The error message says it can't find the static method of signature:
public static void main(String[] arg);

Your code is missing the "String[] arg" parameters.

Good luck, week-end is here.
 
O

ohaya

JScoobyCed said:
Hi,

It's been awhile since I've tried to run any Java applications on this
one machine, but when I tried tonight, I am getting some really strange
problems.

Here's a small application (test.java):

public class test {
public static void main () {
}
}

This compiles ok, but when I run it ("java test"), I am getting:

"Exception in thread "main" java.lang.NoSuchMethodError: main"

Yes, I guess it's been a long day.
The error message says it can't find the static method of signature:
public static void main(String[] arg);

Your code is missing the "String[] arg" parameters.

Good luck, week-end is here.


JScooby,

Thanks! That's what I get for working late at night!

Besides the "arg" thing, I had to include "." in the classpath to get
this working (e.g., "java -classpath .;<my other Jars> test").

Jim
 
T

Thomas G. Marshall

ohaya coughed up:
JScoobyCed wrote:
....[rip]...
The error message says it can't find the static method of signature:
public static void main(String[] arg);

Your code is missing the "String[] arg" parameters.
....[rip]...

Thanks! That's what I get for working late at night!

Besides the "arg" thing, [...]


Since this seemed like a beginner question, I thought I'd follow up with
something beginner to make sure something important is clear, on the off
chance you did not know it.

Do you realize that

public static void main()

as you made it is a perfectly legal method? It's just that it is a
different method entirely (through overloading) than what java was looking
for (as the application entry point).

....[rip]...
 
O

ohaya

Since this seemed like a beginner question, I thought I'd follow up with
something beginner to make sure something important is clear, on the off
chance you did not know it.

Do you realize that

public static void main()

as you made it is a perfectly legal method? It's just that it is a
different method entirely (through overloading) than what java was looking
for (as the application entry point).


Thomas,

Thanks. Yes, I think I knew that subliminally :).

All kidding aside, I appreciate your comment. By way of explanation, I
was so surprised when I ran into the problem, I immediately started
thinking that there was something wrong with the environment on that
machine. The main reason for my post was that I had been staring at
this 3-4 lines of code for quite awhile, and I really needed "another
pair of eyes". I suppose that I could've just gone to bed, and that
might've worked just as well :).

Thanks,
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top