Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  LWJGL library path for Eclipse  (Read 2064 times)
0 Members and 1 Guest are viewing this topic.
Offline StrideColossus
« Posted 2014-03-03 10:49:00 »

To run an application or unit-test using LWJGL one has to set the java.library.path VM parameter to point to a directory containing the native DLLs.

I have this working fine for my maven build on the command line using a surefire plugin, but it would be nice to get it working within Eclipse.  Obviously I can set the VM parameter in the run configuration but it's painful, especially if I'm writing unit-tests: every test has to have its own run config that I have to set manually.

Done some googling, I can find lots about setting this up for a maven build but not for Eclipse itself.  Get the feeling I'm missing some cunning trick - is there some way to set this 'globally' for an Eclipse project? 

- stride
Offline SilverTiger

Junior Member


Medals: 4
Exp: 2 years


がんばってください!


« Reply #1 - Posted 2014-03-03 22:11:31 »

I'm not sure if it is that what you ask, but you can set the directory with @BeforeClass (I assumed that you use JUnit for the Tests):

1  
2  
3  
4  
@BeforeClass
public void setLwjglDirectory() {
    System.setProperty("org.lwjgl.librarypath", new File("path/to/natives").getAbsolutePath());
}

Alternatively you could also set the property as the first call in your main method.
Or were you looking for something like this?
I hope that helped Smiley
Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Reply #2 - Posted 2014-03-15 10:15:11 »

Would you mind posting your maven config? I am currently bothering with the same thing but I can't get it to run for some reason :/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StrideColossus
« Reply #3 - Posted 2014-03-23 12:35:25 »

Quote from: SilverTiger
...

That suggestion works nicely, in fact I have a custom JUnit test-runner that creates a LWJGL display so there is an active OpenGL context for the tests to use.

One slight change is that you have to set a string parameter as the property:

1  
      System.setProperty( "org.lwjgl.librarypath", new File( "target/natives" ).getAbsolutePath() );


i.e. the absolute path at the end.

Would you mind posting your maven config? I am currently bothering with the same thing but I can't get it to run for some reason :/

Sorry hadn't noticed this reply, here's an extract from the POM:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
   <properties>
      <lwjgl.version>2.9.0</lwjgl.version>
   </properties>

   <build>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
               <source>1.7</source>
               <target>1.7</target>
            </configuration>
         </plugin>
         
         <plugin>
            <groupId>com.googlecode.mavennatives</groupId>
            <artifactId>maven-nativedependencies-plugin</artifactId>
            <version>0.0.7</version>
            <executions>
               <execution>
                  <id>unpacknatives</id>
                  <phase>generate-resources</phase>
                  <goals>
                     <goal>copy</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
               <forkMode>once</forkMode>
               <argLine>-Dorg.lwjgl.librarypath=target/natives</argLine>
            </configuration>
         </plugin>
      </plugins>
   </build>


Hope this helps.

- stride
Offline SilverTiger

Junior Member


Medals: 4
Exp: 2 years


がんばってください!


« Reply #4 - Posted 2014-03-23 17:32:07 »

One slight change is that you have to set a string parameter as the property:

1  
      System.setProperty( "org.lwjgl.librarypath", new File( "target/natives" ).getAbsolutePath() );


i.e. the absolute path at the end.

Oh... you're right, I overlooked that! Thanks Wink
Fixed it Smiley
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.

Pippogeek (37 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (30 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (52 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!