Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

JNI loadlibrary choosing dll or so

Thread view: 
Marcelo - 22 Jan 2006 22:00 GMT
Dear programmers,

I am having some trouble in order to determine the OS used by the JVM. I would
like to load some libraries but i don't know the system that is running it.

I would like to do something like:

static{
    if(Linux)
        System.loadLibrary("libHello.so");
    if(Windows)
        System.loadLibrary("Hello.dll");
}

Can you help me, please?

thanks a lot,

Marcelo
Danno - 23 Jan 2006 05:54 GMT
Too much work

http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html#wp679

package pkg;
class Cls {
    native double f(int i, String s);
    static {
        System.loadLibrary("pkg_Cls");
    }
}

Java will convert it automatically depending on the system.  You may
have to do something else if you have code specific to Unix based OSs.
Gordon Beaton - 23 Jan 2006 06:47 GMT
> I would like to do something like:
>
[quoted text clipped - 4 lines]
>         System.loadLibrary("Hello.dll");
> }

This will fail in both cases. Juse specify the base name of the
library, i.e.:

 System.loadLibrary("Hello");

The JVM will load "libHello.so" or "Hello.dll", whichever is
appropriate for the platform.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.