Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  New to Slick2D, help getting started  (Read 12341 times)
0 Members and 1 Guest are viewing this topic.
Offline neoskunk

Junior Member





« Posted 2010-09-14 06:36:52 »

Ok so I don't know who saw my other post but I'm trying to convert my game to Slick2D but I am having a bit of trouble getting started.  Everything compiles correctly but when I try and run just an empty application with Slick2D i get "Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path" what all do i have to do to use Slick?  I added slick.jar, lwjgl.jar, and ibxm.jar to my project.  Apparently I'm missing another step....

Also just out of curiousity what is ibxm.jar?  I just added it according to some tutorial.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #1 - Posted 2010-09-14 10:16:32 »

That is a common error people new to slick/lwjgl get.

Remember LWJGL has two parts, a java part and a native code part.

so

1) you must add the java part (lwjgl.jar), it appears you have done this.

2) the error relates to the lwjgl not finding the native files (*.dll on windows, *.so on linux, etc). You must either set your IDE to point to the folder containing them or set a VM argument -Djava.library.path="folder contain natives" which points to the native files. This will allow LWJGL to find the native files.


ibxm.jar is a library which you can use with Slick2D to play MOD/XM sound files, its optional so if you not using MOD or XM files you don't need it.
Offline neoskunk

Junior Member





« Reply #2 - Posted 2010-09-14 12:05:14 »

ok cool so i need to add slick.jar and lwjgl.jar as well as add the natives to the VM.

another question.  say I want to distribute my game, how is that handled?  do i include all three natives (ie. windows, mac, linux)?  package it all into a jar?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #3 - Posted 2010-09-14 13:52:04 »

another question.  say I want to distribute my game, how is that handled?  do i include all three natives (ie. windows, mac, linux)?  package it all into a jar?

This is different depending on the type of deployment method you choose, for Java Web Start and Java Applets you will put the natives into jars (one jar for each platform, all the natives for each platform will be in one jar).

For deployment as an executable jar or batch script the natives will be in folders (not in jars) to which you simply link to on the classpath with the -Djava.library.path="path" parameter.
Offline neoskunk

Junior Member





« Reply #4 - Posted 2010-09-14 23:08:37 »

ok still having problems.  I extracted the files from natives-win32.jar and got lwjgl.dll, jinput-dx8.dll, jinput-raw.dll, and openal32.dll.  I put all of these in a folder.  From the command line I tried to set the VM argument like you said but it keeps telling me that it can't find the main class.  What am i doing wrong?  can you tell me exactly what i have to type in the command line?

i was doing:  java -Djava.library.path="folder location"
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #5 - Posted 2010-09-14 23:22:50 »

which IDE are you using?

put the files somewhere like the natives inside c:\lwjgl

then you'd use java -Djava.library.path="c:\lwjgl"
Offline neoskunk

Junior Member





« Reply #6 - Posted 2010-09-14 23:43:45 »

I'm using JCreator and whenever i type in java -Djava.library.path="c:\lwjgl" the command outputs the same help stuff as if i just typed java.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #7 - Posted 2010-09-14 23:47:56 »

can't really help with JCreator since I use Eclipse.

What you can do is have a look here http://lwjgl.org/installation.php
Its a small guide on how to setup lwjgl with JCreator, not sure how up to date the guide is though.
Offline neoskunk

Junior Member





« Reply #8 - Posted 2010-09-15 00:30:59 »

I still can't get it to work. This doesn't make any sense.  I wonder if there is a problem with me running Java 32 bit even though my machine is 64 bit.  I guess I'll try using eclipse and see if that changes anything
Offline neoskunk

Junior Member





« Reply #9 - Posted 2010-09-15 03:29:14 »

just out of curiousity can 64 bit systems use the 32 bit natives?  I downloaded lwjgl and they have both 32 bit and 64 bit natives included.  granted this has not solved my problem but again assuming that i get this working how does that play into distribution? just include both sets of natives?

edit: upon using NetBeans it works flawlessly.  Also I used the 32 bit .dlls and it ran on my machine so I guess they do work.

However, what if the user has the 64 bit JRE.  Would they too be able to use the 32 bit .dlls?

haha sorry for being all over the board with the questions.  At least i can start coding using netbeans.  hopefully i'll leave you alone soon kapta Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2010-09-18 01:09:04 »

n bit JRE => n bit libs

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline neoskunk

Junior Member





« Reply #11 - Posted 2010-09-18 22:42:23 »

For deployment as an executable jar or batch script the natives will be in folders (not in jars) to which you simply link to on the classpath with the -Djava.library.path="path" parameter.

for an executable jar how do you set the -Djava.library.path="path" ??
do i just put this path in the class-path: in the manifest file?

sorry I tried searching the web and can't find much on this....

thanks riven.  so for distribution i should put the 64 bit and 32 bit dlls in the windows natives file?  will the JRE automatically pick the correct ones?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #12 - Posted 2010-09-19 00:24:43 »

You can even set the parameter within your app:

1  
System.setProperty("java.library.path", "...")


Naturally, you cannot load libs from within the JAR, as the OS has to load them as files.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline neoskunk

Junior Member





« Reply #13 - Posted 2010-09-19 00:51:51 »

where would this line of code go in my app? 
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2010-09-19 00:58:39 »

Before you do anything LWJGL / Slick2D related.

A safe place would be the first line of your main method.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #15 - Posted 2010-09-19 12:02:12 »

yup as Riven mentioned above, you can use the setProperty stuff to set the path to the natives folder outside your executable jar.

Here is an example of how to use batch scripts to distribute your app.
Offline nsigma
« Reply #16 - Posted 2010-09-20 13:09:40 »


Naturally, you cannot load libs from within the JAR, as the OS has to load them as files.

OK, this is probably a bit off-topic for the original post, but ..

I've always been impressed by the way that the JNA library extracts and runs its native code directly from a JAR.  Alright, it's extracting them to the temp directory so that the OS can load them as a file, but this makes setup and distribution so much simpler - just put the JAR on the classpath.  I don't think it's a solution that would work for everything, but would love to see this principle used more.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #17 - Posted 2010-09-20 14:32:21 »

I don't think it's a solution that would work for everything, but would love to see this principle used more.

I do think that it would work for 'everything', and it's not hard to code that functionality.

Writing it in the (system) temp-file wouldn't be my first choice, as it can be overwritten accidently or even intentionally. It's better to extract it where you have exclusive privileges.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline nsigma
« Reply #18 - Posted 2010-09-20 14:46:52 »

I do think that it would work for 'everything', and it's not hard to code that functionality.

Writing it in the (system) temp-file wouldn't be my first choice, as it can be overwritten accidently or even intentionally. It's better to extract it where you have exclusive privileges.

With JNA it gets written to the temp file system purely for that one loading, and is deleted on VM exit.  Personally, I like that better.  But, anything that worked from the classpath would be an improvement.

The one case I think this might not work is for libraries where setting java.library.path doesn't work either.  Eg. JMF (yuck!) has multiple libs that link off each other.  The first is loaded from the Java library path, but the links are loaded from the system library path.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!