Click here to Skip to main content
15,887,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to know how to import a dll or dll's into my java project

But I get this error when I try this method

MY ERROR I GET..... THEY MUST BE A EASIER WAY TO DO THIS FOR SURE C# MAKES IT EASY SO I NEED A EASY METHOD FOR JAVA AS WELL ANY ADVICE

Exception in thread "main" java.lang.UnsatisfiedLinkError: no binkw32.dll in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at Game.main(Game.java:148)



import java.io.File;
import java.util.Scanner;

public class Game {

 static boolean running = false;
 private Thread thread;
 


private Game(){

    //no other functions should be here
    initializeGame();
}


private void initializeGame() {
    //Create your game objects and get input    
}

private synchronized void startGame() {
    if(running){
        System.out.println("[DEBUG] Already running");
        return;
    }

    thread = new Thread();
    running = true;
    thread.start(); 
    run();
}




public void run(){
    long lastTime = System.nanoTime();
    final double ticks = 60.0;
    double ns = 1000000000 / ticks;
    double delta = 0;
    int updates = 0;
    int frames = 0;
    long timer = System.currentTimeMillis();

    //Game Loop
    while(running){

        long now = System.nanoTime();
        delta += (now - lastTime)/ns;
        lastTime = now;

        if(delta >= 1){
            tick();
            delta--;
            updates++;
        }
        render();
        frames++;

        if(System.currentTimeMillis() - timer >= 1000){
            timer += 1000;

            frames = 0;
            updates = 0;    
        }
    }
    stop();
}

//Everything that updates
private void tick(){


}
//Everything that renders 
private void render(){
	
	try {
		
		Scanner x = new Scanner (new File("DATA_1.PAK"));
		x = new Scanner (new File("DATA_2.PAK"));
		x = new Scanner (new File("DATA_3.PAK"));
		x = new Scanner (new File("DATA_4.PAK"));
		x = new Scanner (new File("DATA_5.PAK"));
		x = new Scanner (new File("DATA_6.PAK"));
		x = new Scanner (new File("DATA_7.PAK"));
		x = new Scanner (new File("DATA_8.PAK"));
		x = new Scanner (new File("DATA.PAK"));
		x = new Scanner (new File("DATAA_1.PAK"));
		x = new Scanner (new File("DATAA_2.PAK"));
		x = new Scanner (new File("DATAA_3.PAK"));
		x = new Scanner (new File("DATAA_4.PAK"));
		x = new Scanner (new File("DATAA_5.PAK"));
		x = new Scanner (new File("DATAA_6.PAK"));
		x = new Scanner (new File("DATAA_7.PAK"));
		x = new Scanner (new File("DATAA_8.PAK"));
		x = new Scanner (new File("DATAA.PAK"));
		x = new Scanner (new File("DATAE_1.PAK"));
		x = new Scanner (new File("DATAE_2.PAK"));
		x = new Scanner (new File("DATAE_3.PAK"));
		x = new Scanner (new File("DATAE_4.PAK"));
		x = new Scanner (new File("DATAE_5.PAK"));
		x = new Scanner (new File("DATAE_6.PAK"));
		x = new Scanner (new File("DATAE_7.PAK"));
		x = new Scanner (new File("DATAE_8.PAK"));
		x = new Scanner (new File("DATAE.PAK"));
		x = new Scanner (new File("DATAL_1.PAK"));
		x = new Scanner (new File("DATAL_2.PAK"));
		x = new Scanner (new File("DATAL_3.PAK"));
		x = new Scanner (new File("DATAL_4.PAK"));
		x = new Scanner (new File("DATAL_5.PAK"));
		x = new Scanner (new File("DATAL_6.PAK"));
		x = new Scanner (new File("DATAL_7.PAK"));
		x = new Scanner (new File("DATAL_8.PAK"));
		x = new Scanner (new File("DATAL.PAK"));

}
	
	catch (Exception e) {
		
		System.out.println("Could not read file");
		
		
	}
	
}

private synchronized void stop() {
    if(!running){
        return;
    }

    running = false;
    try{
        //Pause thread
        thread.join();
    }catch(InterruptedException e){
        e.printStackTrace();
    }
    System.exit(1);

}

public static void main(String []args){
	
	System.loadLibrary("d3d8.dll");
	System.loadLibrary("binkw32.dll");
	System.loadLibrary("EngineServer.dll");
	System.loadLibrary("MEGA.PropertyGrid.dll");
	System.loadLibrary("GameDatabase.dll");
	System.loadLibrary("StringEditRuntime.dll");
	System.loadLibrary("GameClient.dll");

    Game game = new Game();
    game.startGame();
    

}

}


What I have tried:

Ive tried this method

public static void main(String []args){
	
	System.loadLibrary("d3d8.dll");
	System.loadLibrary("binkw32.dll");
	System.loadLibrary("EngineServer.dll");
	System.loadLibrary("MEGA.PropertyGrid.dll");
	System.loadLibrary("GameDatabase.dll");
	System.loadLibrary("StringEditRuntime.dll");
	System.loadLibrary("GameClient.dll");

    
    

}
Posted
Updated 30-Mar-18 22:22pm

1 solution

no binkw32.dll in java.library.path

That means that the Java VM cannot find the dll. You need to add its path into the command line like:
java -Djava.library.path=<path_to_dll> <main_class>

Alternatively you can set it in the environment variable LD_LIBRARY_PATH.
 
Share this answer
 
Comments
Member 13755707 31-Mar-18 4:31am    
Where is the enviroment varible LD_LIBRARY_PATH located at
Richard MacCutchan 31-Mar-18 4:43am    
In the environment ...
Member 13755707 31-Mar-18 4:31am    
can you just give me a little text guide on your answer thanks it would save me more time looking around the interent thanks...
Richard MacCutchan 31-Mar-18 4:44am    
If you are running in eclipse then use the eclipse menu to find out where to add library paths. If you are running from the command line, then see my suggestions above.
Member 13755707 31-Mar-18 7:18am    
Okay thanks I will try thanks for the help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900