Jump to content
  • Advertisement
Sign in to follow this  
daemon2008

[java] Compiling Jar in Eclipse with LWJGL

This topic is 3855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Sorry to ask probs a very basic question. But i'm trying to compile my project that uses the LWJGL jar files. The main interface is in AWT. One of the JButtons on the interface opens up a new render window from the LWJGL library. The project works fine in eclipse and all the libraries are set up. However when i compile to a jar with all the LWJGL jars included, the 'Render' button doesnt do anything, i.e doesnt open a LWJGL window. The class path i have is: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="src"/> <classpathentry exported="true" kind="lib" path="lwjgl.jar"/> <classpathentry exported="true" kind="lib" path="lwjgl_util.jar"/> <classpathentry exported="true" kind="lib" path="vecmath.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Ive been playing around with this for hours and cant get the render button to respond. Any ideas? Thanks! Dan

Share this post


Link to post
Share on other sites
Advertisement
Assuming it's possible to open a LWJGL window from AWT (I never tried, but I think it is): run it from a console, there should be some error being reported. Probably you did not include the LWJGL dll's in the correct place (just the jars is not enough) - I think having them in the same directory should work, otherwise use -Djava.library.path=path/to/dlls

What I usually do is write an ant script that builds the jar and copies all jars, library files, and data files to a separate directory. Eclipse makes this really easy, just add a script to your project, right click and select run.

Share this post


Link to post
Share on other sites
Hi, thanks for the reply.

Ive put the dll's and the jar files in the same directory but still no luck.

Where do i use 'Djava.library.path=path/to/dlls'?

Thanks
Dan

Share this post


Link to post
Share on other sites
As argument to the VM.

java -Djava.library.path=path/to/dll -jar yourgame.jar

Run it from a console window. But you shouldn't need to add the path if it's in the same directory. There's no error being reported on the console when you press the button?

Share this post


Link to post
Share on other sites
Hey,

Just ran it from the console. It says 'Unable to access Jar File' when i use that line. It's strange because when you execute the jar file normally by double clicking it it runs ok (except without the working button), but not from the command line? :s

Thanks
Dan

Share this post


Link to post
Share on other sites
It can't find yourgame.jar since it doesn't exist, or you're in the wrong directory... Don't use it verbatim. You need to substitute your jar's name for "yourgame.jar", and something else for "path/to/dll". You also have to navigate to the directory with the jars first.

Share this post


Link to post
Share on other sites
hi lightbringer,

Thanks for the help so far.

Yeh ive been using my own setup, the printout from the console is:

C:\Documents and Settings\Daniel Barrett>java -Djava.library.path="org.eclipse.j
dt.launching.JRE_CONTAINER" diss10.jar
Exception in thread "main" java.lang.NoClassDefFoundError: diss10/jar


I've also tried:

C:\Documents and Settings\Daniel Barrett>java -Djava.library.path="C:\Program Fi
les\Java\jre1.6.0_02" diss10.jar
Exception in thread "main" java.lang.NoClassDefFoundError: diss10/jar


Unfortunately they teach you everything on my uni course except how to compile jars :s.

Thanks
Dan

Share this post


Link to post
Share on other sites
library path should be the path to lwjgl's dlls, not one of those you put. If it's in the same directory, leave it out, or use a dot. You also did not specify that you are loading a jar and not a class.

Try this:
java -Djava.library.path=. -jar diss10.jar

or alternatively:
java -jar diss10.jar

Then post back your results. This is assuming, of course, that you already compiled a jar called diss10.jar. If you didn't, then use an ant script

Share this post


Link to post
Share on other sites
Hey,

for:

java -Djava.library.path=. -jar diss10.jar

It says:

Exception in thread "main" java.lang.NoClassDefFoundError: diss10/jar


for:
java -jar diss10.jar

It says:

Unable to access jarfile diss10.jar

Sorry i didnt mention the jar part :(

Thanks
Dan

Share this post


Link to post
Share on other sites
Are you running that from the directory containing your jar?

Quote:
Original post by daemon2008
Sorry i didnt mention the jar part :(

No no I just mean that you need to use -jar switch for jars :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!