Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

dll with java

  Asked By: Glenn    Date: Feb 11    Category: Java    Views: 818
  

i am still new in java..
my problem that i need to make a dll with java where i can use it with any other
application made with e.g : C++,C# or VBasic??
by an easy way
and must i need JVM to use it?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Carl Woods     Answered On: Feb 11

How can I access Firebird with Netbeans, I'd like to know if exists
free objects like JDBEdit, JDBNavigator etc....

 
Answer #2    Answered By: Adal Fischer     Answered On: Feb 11

A note on using runtime loaded dynamical code in Java.

No, as the previous posters have pointed out, DLL's does not work well with
Java. But since I am guessing that you still want dynamical loading in your
Java program atleast this can be achieved.

My favorite way of doing this (maybe there are others) is to work with an
interface (or base class) some properties file (haven't really seen the need
for LDAP/Contexts but they would do the trick as well) and Class.forName().

If the above terms doesnt make sense to you look them up at
http://java.sun.com

The core of my dynamic class loading would then look something like this:

String className = System.getProperty("mySystem.mySomething.className");
obj = (MySomething)( Class.forName( className ).newInstance());

Of course I could get my clas name from some other place than the system
properties (like a properties file). Also the best place to place this code
would be in a factory:

class MyFactory {
MySomething obj = null;

public synchornized MySomething getMySomething () {
if ( obj == null ) {
String className = ...;
obj = (MySomething)...;
}
return obj;
}
}

By using this factory implementation you make the creation of the dynamic
object only once... but the cost is that the creation method has to be
synchronized. You may also wish to make the factory static.

If you want to know more about factories look it up at
http://java.sun.com/blueprints/patterns/index.html (or any other online - or
book - resource on patterns).

I hope this answers some of the questions on dynamic loading in Java.

 
Didn't find what you were looking for? Find more on dll with java Or get search suggestion and latest updates.




Tagged: