Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  -Djava.library.path and System.setProperty  (Read 1893 times)
0 Members and 2 Guests are viewing this topic.
Offline mgm

JGO n00b
*

Posts: 6



« on: 2010-11-05 15:26:13 »

I have searched a bit before asking. I use netbeans. In my project, I use Slick and so lwjgl.
When I use-Djava... it works very well. on the other hand, when I use System.setProperty("java.library.path", "identic path")

IT give me the same path but lwjgl doesn't load...it said me unsatisfiedlink error no lwjgl in java.lib...
why?
my first line of the main is setProperty... Huh

its cool to develop but if my programme does not run out of the IDE its useless... Undecided

someone can give me a clue? or explain to me why?
my main class
Quote
package infl3Client;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.SlickException;

public class Main {
   public static void main(String[] args){
      System.setProperty("java.library.path", System.getProperty("user.dir")+"/res/lib/");
      System.out.println(System.getProperty("java.library.path"));
               
      try {
         AppGameContainer container = new AppGameContainer(new Game());
         container.setDisplayMode(1024,768,false);
         container.start();
      } catch (SlickException e) {}
   }
}
Offline cylab

JGO Kernel
*****

Posts: 1940
Medals: 27



« Reply #1 on: 2010-11-05 17:00:28 »

Unfortunately simply calling setProperty() doesn't do the trick. There was a lengthy thread about this, leading to this solution

Mathias - I Know What [you] Did Last Summer!
Offline mgm

JGO n00b
*

Posts: 6



« Reply #2 on: 2010-11-05 18:54:02 »

thanks it's very helpful, its work ^^ (for the moment  Grin) I ' ll modify it to be more adapted to my needs.
Games published by our own members! Go get 'em!
Offline kappa
« League of Dukes »

JGO Kernel
*****

Posts: 2358
Medals: 59


★★★★★


« Reply #3 on: 2010-11-05 19:05:30 »

The above seems like a very hacky way to solve the problem.

Since you are using LWJGL you can simply use

1  
System.setProperty("org.lwjgl.librarypath", path);


instead of "java.library.path" to make it work.
Offline mgm

JGO n00b
*

Posts: 6



« Reply #4 on: 2010-11-05 19:45:19 »

yes it work too and is more simply but I need more than lwjgl... Jinput too and in future, need others too so I think the hacky way is better when you need more than one or two natives sources
Offline Nate

JGO Neuromancer
****

Posts: 1062
Medals: 30


mooooo


« Reply #5 on: 2010-11-05 20:23:48 »

If you use your own classloader to load the classes that you don't control that are loading native libs, then you can override ClassLoader#findLibrary to control where the native libs are found.

Offline kappa
« League of Dukes »

JGO Kernel
*****

Posts: 2358
Medals: 59


★★★★★


« Reply #6 on: 2010-11-05 20:39:17 »

yes it work too and is more simply but I need more than lwjgl... Jinput too and in future, need others too so I think the hacky way is better when you need more than one or two natives sources

for Jinput you can use
1  
System.setProperty("net.java.games.input.librarypath", path);


however, if you need more natives then that, then cylabs method above should work pretty well.
Offline mgm

JGO n00b
*

Posts: 6



« Reply #7 on: 2010-11-06 03:59:08 »

I have not think about it... I do not control on what is loaded...

@kapta : Where did you find thoses lines of property which are very simple to use and maintain... Where did you find the key string associated to the native ?
Offline kappa
« League of Dukes »

JGO Kernel
*****

Posts: 2358
Medals: 59


★★★★★


« Reply #8 on: 2010-11-06 08:51:05 »

@kapta : Where did you find thoses lines of property which are very simple to use and maintain... Where did you find the key string associated to the native ?

in the source code for the two libraries, when I was looking for similar functionality.
Offline mgm

JGO n00b
*

Posts: 6



« Reply #9 on: 2010-11-06 11:28:05 »

Thanks I have not thinked about looking in source code  Roll Eyes
With a line like that its more easy to maintain the code and to read it Grin
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.079 seconds with 19 queries.