tags:

views:

159

answers:

2

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.

A: 

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
Shashank T
What? I'm trying to use the pre-existent library lwgjl.
Vuntic
A: 

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

sushant
That really doesn't help at all... "I really have been searching for hours." Sorry.
Vuntic
Assuming your jar is lwjgl.jar, then you first need to compile your java file.Assuming lwjgl is in current directory:javac -classpath lwjgl.jar gwison/G.java
sushant
Turns out that I was doing the right thing all along, at least with the classpath. The problem I'm having comes from an ENTIRELY different source.Apologies.
Vuntic