1

I successfully compiled my source using this command:

javac -classpath "..\lwjgl-2.7.1\jar\lwjgl.jar" Game.java 

However, when I try to run it using:

java -classpath "..\lwjgl-2.7.1\jar\lwjgl.jar" Game 

, it gives me an error:

Error: Could not find or load main class Game 

What have I done wrong!? :(

I am certain that there are no syntactical errors and class labeling anomalies.

EDIT: I've also tried running the program using this command, but still nothing. T.T

java -cp "..\lwjgl-2.7.1\jar\lwjgl.jar" -Djava.library.path="..\lwjgl-2.7.1\native\windows" Game 
6
  • it has to be java -classpath "jarpath" <classname>. Commented Aug 11, 2011 at 7:27
  • Sorry, I mistyped the question, but it's revised now. The command I used to run it was java -classpath "..\lwjgl-2.7.1\jar\lwjgl.jar" Game Commented Aug 11, 2011 at 7:39
  • Does your Game class has a main() method? Commented Aug 11, 2011 at 7:41
  • Yes, it does. I even tried a blank source with just the imports, the constructor method and the main method, but still nothing. Commented Aug 11, 2011 at 7:47
  • Does the Game class reside in some package? If so, you've to specify it. Commented Aug 11, 2011 at 8:29

3 Answers 3

2

Here is the answer, after endless hours of sitting on my toilet...

java -cp "..\lwjgl-2.7.1\jar\lwjgl.jar"; -Djava.library.path="..\lwjgl-2.7.1\native\windows" Game 

Note the semi-colon after the -cp. The SEMI-COLON. That was all that I was lacking. A FRIGGIN' SEMI-COLON.

I hope nobody commits the mistake I did.

Sign up to request clarification or add additional context in comments.

Comments

0

It has to be

java -classpath "..\lwjgl-2.7.1\jar\lwjgl.jar" Game 

1 Comment

Oh, sorry about that. That's the command I used, I just mistyped the question.
0

Is Game.class inside of that jar file? If not, you probably need to include the path to the class file as well. For the current working directory, try:

 java -classpath "../lwjgl-2.7.1/jar/lwjgl.jar:." Game 

(Maybe that : should be a ; on Windows).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.