lwjgl 101: How can I write the basics?
EDIT: So apparently I was doing everything right, but I had a different problem that made it look as if I was doing something wrong. Sorry about that. --me, newbie
This ought to be really simple, but I cannot for the life of me figure out how to compile anything with lwjgl and have it work. I can write something like
package gwison;
import org.lwjgl.Sys;
public class G
{
public static void main(String[] args)
{
System.out.println(Sys.getTime());
}
}
and I can easily compile a program with several classes in different packages, as long as I wrote all the classes myself. But I have no clue how to make G work. I think it has something to do with classpathes? Maybe? Help?
I really have been searching for hours, but the most basic tutorials assume you know how to do开发者_运维知识库 this!
Edit: oh and I'm sorry if I've violated stackoverflow conventions; I did try not to but this is my first action here.
You can try out this way create a folder called TestProject inside it create one folder gwison like D:\TestProject\gwison Create two more folder in same TestFolder like this D:\TestProject\org\lwjgl. Now create a Class G in gwison folder like u created above.Create one more class Sys like this
package org.lwjgl;
import java.util.Date;
public class Sys {
public static Date getTime(){
return new Date();
}
}
now from command promt go to this path D:\TestFolder and run the below command:
javac gwison\G.java
This will complie your code, now run one more command:
java gwison.G
This will run your code without any error and you will get a output like this:
Sun May 02 13:17:11 IST 2010
You need to make sure the jars are in the classpath while compiling and running. Place your lwjgl jars in the classpath during compilation More info :
http://en.wikipedia.org/wiki/Classpath_%28Java%29
精彩评论