Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Using Java Library (DLL)

This topic is 5202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im trying to use a DLL libarary (extension) in my java app. they problem isnt compiling, its running ... is there any way to let the VM know where the DLL is located? the reason im asking, is its for one of my Uni assignments and i dont have write access to the hard-drive (ie. c:/windows/systems32/) the library is JOGL if anyone wants to know. thanks in advance.. Danushka

Share this post

Link to post
Share on other sites

public class MyClass{



public static void main(String[] args){

// Call native class methods....

Also make sure that the dll is in your classpath

java -classpath "C:\LocationOfDll\;"

If you are invoking the VM from C/C++ code then there is a function provided by jni.h that allow you to set the classpath.

Visit http://java.sun.com/ and search for the JNI tutorial.. It contains pretty straight forward examples of invoking/embedding and the extension mecahnism

edit: accidentally posted it.. doh..!

[edited by - Rickmeister on March 23, 2004 5:30:51 AM]

Share this post

Link to post
Share on other sites
Or rather than mussing with the class path, run java with this param: -Djava.library.path=/path/to/library/

Share this post

Link to post
Share on other sites
yea, none of that stuff worked...

i can get it to compile, but when i run it i get the following:
[java cMain -Djava.library.path=g:/java/jenga/]

Exception in thread "main" java.lang.NoClassDefFoundError: net/java/games/jogl/G
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

heres the source for the applet im trying to run...

import javax.swing.JApplet;
import net.java.games.jogl.*;

import java.awt.*;

public class cMain extends JApplet implements GLEventListener {

static {

public void init() {
GLCapabilities glc = new GLCapabilities();

GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(glc);

getContentPane().add(canvas, BorderLayout.CENTER);

public void display(GLDrawable gld) {
// the drawing code


public void displayChanged(GLDrawable gld, boolean arg1, boolean arg2) {

public void init(GLDrawable gld) {
// make sure we don''t do anything wrong with OpenGL

gld.setGL(new DebugGL(gld.getGL()));
// set the clear color, this only needs to be done once at the beginning

// of the program after the GL context has been created

gld.getGL().glClearColor(0.0f, 0.0f, 0.75f, 1.0f);

public void reshape(
GLDrawable arg0,
int arg1,
int arg2,
int arg3,
int arg4) {

Share this post

Link to post
Share on other sites
Make sure you have jogl.jar in your classpath. Or even better, put jar files in lib/ext directory of your JVM and dll in bin.
BTW you don't need to load jogl native libraries, it is already done (probably by GLDrawable).

EDIT : For applets it should be a bit harder, because the security manager won't let you load native libraries without guarantees. Can't help you much, I only use standard apps

[edited by - overnhet on March 24, 2004 4:04:53 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!