Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (784)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (859)
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 8385 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:


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

Thanks in advance!

/ Anders

Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

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


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?


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:
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:
//Code cut out, it's not hard, just look up the System.getProperty("") field on the internet
            case WINDOWS:
            case MACOSX:
            case LINUX: case 4231: //Solaris

:p I've had to do this with almost every java library I"ve ever used (Jogl, Gstreamer, etc.) - 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  

hadezbladez (1655 views)
2018-11-16 13:46:03

hadezbladez (667 views)
2018-11-16 13:41:33

hadezbladez (1654 views)
2018-11-16 13:35:35

hadezbladez (351 views)
2018-11-16 13:32:03

EgonOlsen (2705 views)
2018-06-10 19:43:48

EgonOlsen (2971 views)
2018-06-10 19:43:44

EgonOlsen (1657 views)
2018-06-10 19:43:20

DesertCoockie (2373 views)
2018-05-13 18:23:11

nelsongames (2286 views)
2018-04-24 18:15:36

nelsongames (2977 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 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‑
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!