Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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  
  Load DLL outside or inside JAR?  (Read 4039 times)
0 Members and 1 Guest are viewing this topic.
Offline wrAthchild

Senior Newbie





« Posted 2008-07-16 23:10:05 »

First of all: the return of endolf gives me hope, I'm hoping for some guidance Smiley

I just couldnt let the old JInput version be... I like the way the Axis class work and i.e. how the game characters move based on this, so:

Been trying for 3 days to load a native library file, dxinput.dll (yes from an older JInput version), to make my game work with gamepad support.
That is, when running the app as a JAR; in NetBeans all functionality is there. I've totally given up on loading the dll from within the JAR (from a "lib" folder), but I even fail to load it in any way; with an absolut path, say "C:/Test/dxinput.dll" using the System.load() or System.loadLibrary().

The files I'm using are these:

jinput.jar
jutils.jar
win32-x86-directinput-plugin.jar
linux.jar
linux-eventinterface-jinput-plugin-0.1.jar
dxinput.dll
libjinput.so
libLinuxEventInterface-i386.so

Please, I NEED help with this, how do I make this work??   Undecided

Thanks in advance!

/ Anders

Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #1 - Posted 2008-07-17 06:20:00 »

Hi

This sounds like a Netbeans setup kind of thing, and I can't help there as I don't use it. Have you tried running from a dos prompt as show in the getting started thread?

Endolf

Offline wrAthchild

Senior Newbie





« Reply #2 - Posted 2008-07-17 12:38:28 »

Thanks for taking the time to answer, feeling better already Smiley

However, the application IS running perfectly in NetBeans with JInput and the above files; my characters move as expected when using my gamepad. The very annoying issue is regarding the deployment of the app - I want to run it as a JAR, with all files included in it. But the gamepad don't get registered somehow; the missing link is dxinput.dll.

So, I don't care anymore if the DLL gets loaded from within the JAR - I just need for it to get loaded at all, at any cost almost  Cool Could you (or someone else ) please explain generally how you would do the following:

1. Bundle the app's files (.class, images, sounds etc) as a JAR. This I know how to do Smiley A bit unsure though on how the manifest file *should* be?
2. Get the app's main class inside the JAR to load a native lib (dxinput.dll in my case), from outside the JAR. Would be satisfied just to create a deployment folder that includes the JAR + the native library, and distribute this folder to anyone who might be interested.

This is all I want to do, getting somewhat desperate now as I feel that this really is a trivial matter? I would be extremely happy if I could make this work, thanks for listening Smiley

/ Anders


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline taifunbrowser

Senior Newbie





« Reply #3 - Posted 2008-07-17 13:48:32 »

I have a solution, but you may / may not like it.

Ok, the reason everything is so difficult is because Jinput uses System.LOADLIBRARY, which is bad. Our goal is to use System.load() on a absolute path to where the dlls are.

So, get the source of jinput (newest version), and make a new class:
1  
2  
3  
4  
5  
6  
package <something>
public class System {
   public static void loadLibrary(String lib_name){
                    return; //We'll completely ignore all loadlibrary calls from jinput.
  }
}


Then, do a FileSearch on all of jinputs classes for "System.loadLibrary" and replace it with "<your package>.System.loadLibrary" It should replace 3-4 instances.

Then, if you export the new jinput as a jar, run your code, nothing will work, because its not loading anything.

So, we can load it ourselves now:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
//Code cut out, it's not hard, just look up the System.getProperty("os.name") field on the internet
switch(ostype){
            case WINDOWS:
               System.load(runningDir+File.separator+"jinput-dx8.dll");
               System.load(runningDir+File.separator+"jinput-raw.dll");
               //System.load(runningDir+File.separator+"jinput-wintab.dll");
              break;
            case MACOSX:
               System.load(runningDir+File.separator+"libjinput-osx.jnilib");
               break;
            case LINUX: case 4231: //Solaris
              System.load(runningDir+File.separator+"libjinput-linux.so");
               break;
            }


:p I've had to do this with almost every java library I"ve ever used (Jogl, Gstreamer, etc.)

http://beam.to/jtouhou - the JTouhou project! Mixed 3d and 2d, a multiplatform port for the classic dojin-soft series by Shanghai alice!
Offline wrAthchild

Senior Newbie





« Reply #4 - Posted 2008-07-17 16:15:42 »

Thanks for clearing things up Smiley

With the risk of sounding like a complete moron now  Shocked :

If I still would like to use the older JInput version I have in my current code (where everything runs/works great in NetBeans with gamepad), can your code above accomplish the same thing, in the case of loading dxinput.dll (the only DLL in this version)?? THAT would be excellent.

You may not have read my other recent posts, but I have got gamepad support working with an executable JAR, together with the latest JInput version.  This might sound offensive to some Wink ; what's the problem if he's already got it working?? Well, I really really would like to work with the old Axis class I have in my current code. It's just a question of loading the DLL for that version....

Many thanks for your input!! I will try your code + some other workarounds I might not have tested yet.

/ Anders


Offline wrAthchild

Senior Newbie





« Reply #5 - Posted 2008-07-17 20:30:17 »

For now I think I have to give up, after 4 days of struggling. I will have to work on modifying my code to suit the latest JInput instead, which for some reason  d o e s  work when executing my app as a JAR. So that's a good thing of course, it's just hard to let go when it *should* be SO simple...

Endolf: if you read this, I would like some help with my other post "Polling two components...". After testing some it feels like the Event class among others, forces me to change the code quite a bit. I'm struggling to poll two components at the same time; gamepad button press + polling left/right on an analog stick for example? Surely this must be possible?

If you or anyone else has some info on this, the above mentioned thread is available Smiley

Good night!

/ Anders
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.

atombrot (25 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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!