Bundling a native library in a jar file

Is it possible to bundle a native library ( a windows dll ) in a jar file. How to let the vm know that the native dll is in a jar file.
Is this possible?
thanks
--kiran                                                                                                                                                                                                                                                                                                                                                   

hello all
i cann't find out (or don't understand) the way what i need. i mean how can i copy the dll file(s) in the windows system diractory? i can put the dll in the jar file then how can i copy that dll after extract?
"daney" said that he have done it.
This certianly is possible. I have done it.
You have to extract the dll from the jar file and write it to a temporary >file in the file system. Then call System.load() on the file you just >extracted.
Do you want to delete the temporary file when you are done with it? >That is a bit more difficult, but it is possible if you use a ClassLoader >to run your code containing native methods.anybody have any idea how he has done? please give some details if anyone have worked on it before.i am waiting for the solutions.
thanks
bashar

Similar Messages

  • Native library & JAR

    Is it possible to add native library into JAR?
    Archive: JarTest.jar
    META-INF/
    META-INF/MANIFEST.MF
    test/
    test/Hello.class
    test/Native.class
    libtestnative.so
    MANIFEST.MF
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.5
    Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
    Main-Class: test.Native
    Bundle-NativeCode: /libtestnative.so;  osname=Linux,       processor=i386This command works perfectly:
    java -Djava.library.path=./lib_native -cp bin test.Native
    but if I use JAR:
    $ java -cp JarTest.jar test.Native
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no testnative in java.library.path
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
            at java.lang.Runtime.loadLibrary0(Runtime.java:822)
            at java.lang.System.loadLibrary(System.java:992)
            at test.Native.<clinit>(Native.java:13)
    I have also tryied:
    java -Djava.library.path=./jar/JarTest.jar -cp ./jar/JarTest.jar test.Native
    java -Djava.library.path=./ -cp ./jar/JarTest.jar test.Native
    With the same result.
    Any help would be realy appreciated.

    One way would be to create a helper class that:
    1- Verifies that the native library is already located in a specific folder (could be the one specified by the user.home system property).
    If so then go to step -3-.
    2- Extracts the native library from the jar (with the Class.getResourceAsStream() method for instance) to the specific folder.
    3- Loads the native library with the System.load() method which requires a complete path name.
    Regards

  • Add jar file to forms application standard java library

    Overall Problem
    I created a jar file using JDeveloper to be loaded as a bean in forms builder. But the jar file ended up being really large because I had to add some standard libraries that JDeveloper knew about but Forms didn't to this jar file, it takes forever to load in my forms application.
    Background
    Jdeveloper has a drop down list of standard libraries that aren't commonly used that a developer can have included/referenced into their java project.
    Oracle Forms Library
    One of the standard libraries in JDeveloper that can be referenced when compiling a project is the Oracle Forms library. I have to reference this library in my compilation of my java project in JDeveloper because some of the java code in this project requires the Oracle Forms library. When the jar file is created in JDeveloper the Oracle Forms Library isn't actuaally physically located anywhere in the jar file that is produced for deployment. But the jar file runs perfectly in my forms application. Forms builder and the forms application server seems to already know about the Oracle Forms library.
    Java Media Framework Library
    There is another standard library listed in JDevelopers drop down list that I recently chose to use in my Java Application, the Java Media Framework library. But my forms application couldn't find any of the Java Media Framework classes when it launched the jar file that was deployed from JDeveloper. Obviously the classes wern't physically located in the jar file I created, because I figured that the forms application server/forms builder would already know about about this standard library that JDeveloper knew about.
    Not very effective Solution
    So I physically put/included the whole Java Media Framework Library into my jar file and then my form launched fine. But it now takes forever to load. How can I add the Java Media Frame work library jar files as one of the standard libraries that the forms builder and application server already sees (Like the Oracle Forms Library) without having to put the library in the forms/java folder and wait for the this jar file to download to the user's cache?
    Side note: The Java Media Framework Library is allowing the ability to launch video from my form. Very useful tool!!! So it would be good if forms had this already added as a standard library like it is in JDeveloper. But I only see the ability to reference this library in DS 10gR2 for JDeveloper.
    Thanks,
    Michelle

    Yes I have successfully been able to run a javabean application that uses the Java Media Framework methods within a forms module. The video seems to play and interact normally in the forms environment (launched from a DS or the AS).
    Basic Requirements
    Develop the java application functionality look and feel, including adding funtionality calls to the JMF library where needed.
    Develop an Oracle Forms Interface wrapper that will be the initial class called from the bean area, to hande any communication between the bean and the form.
    Configure the deployment of the jar to physically include all the needed classes from the JMF library.
    Sign the jar file and make sure it is placed in the forms/java folder and referenced in the appropriate forms configuration files.
    Depending on the type of video that the will be played certain .dll files might need to be added to the users system folder. Using H264 (.mov) should work fine without any extra .dlls.
    Thanks,
    Michelle
    Message was edited by:
    mpoore

  • How to include externel library in JAR file?

    Hi all =)
    I have a program that uses an external library (in a JAR file) I would like to compile my program as a JAR and have it include the external library that it needs to run, so that the external library would not need to be on the computer running my program. How can I do this?
    Thanks =)
    Koneko349
    Message was edited by:
    Koneko349

    Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
    C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
    I do not get this error when I run and use my program from within the IDE.
    The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path=""/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry kind="lib" path="D:/poi.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>I would really like to get this working and I'm very confused XP

  • Load library from JAR file

    Could I ask you guys a stupid question, please?
    I have a library as an JAR file. I build my application as another JAR file, which includes that library file.
    My manifest file is:
    Manifest-Version: 0.1.0
    Class-Path: lib/mysql-connector-java-3.0.17-ga-bin.jar
    Main-Class: com.myappand the build command:
    jar cvfm hello.jar mymanifest -c com  -c libThe result hello.jar file built OK. But when I run it, I have to copy library file to the same folder to the app file.
    Could you tell me how to load the lib file from hello.jar, instead of the lib file?
    Thanks in advance!
    Best regards,
    Lehoanq

    am I right in thinking you've put the mysql jar inside your application jar? jars don't work like that, I'm afraid. it is possible to write a classloader that will load classes from within a jar-inside-a-jar, but it gets rather complicated and messy and isn't worth the hassle to be honest, anyway. we go to some lengths to keep our software modular and separate. imagine, for instance, that a bug is exposed in the mysql driver you're using, and a new release is needed to fix it. the dependency is rooted inside your application, so the whole shebang has to be re-packaged and re-deployed, whereas if your dependencies were inside a lib folder, all that would be needed is to drop the new version of the mysql driver into the lib directory. think "don't put all your eggs in one basket"
    what you want to do is possible, and there are tools around to do it for you, too, but IMHO it's not worth the effort

  • What is the .jar file or library for oracle.iam.identity.rolemgmt.api

    Hi Experts,
    I am using 11.1.1.6.0 version of Jdev.
    I need to use oracle.iam.identity.rolemgmt.api.RoleManager API in my application, but i am not able to find out the library or the jar file required.
    Somebody help me in adding the required libraries please.
    Thanks
    Gopi

    Hi Nishith,
    I am a new joinee.
    Not able to locate OIM_HOME. If you don't mind please give me the detailed steps to locate OIM_HOME.
    Thanks
    Gopi

  • How can  I access my java class file in a .jar file ...PLz Help anyone!!

    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program.
    Plz help ...I have tried all I know in vain.
    Thanks.

    temba wrote:
    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program. You are making little sense. You can't instantiate .java files.
    Plz help ...I have tried all I know in vain.
    Thanks.Could you post WHAT you have tried and also post what error messages you received?

  • Using a Jar file into my jar project (Applet)

    Hy,
    I would like to know how I have to do to put a jar library in my jar file (containing my classes) ?
    I use only 2 classes of that particular jar library (Regex.class & RegRes.class), and when I only put the jar file (patbinfree153.jar), the applet stops when its reaches the first line where i use this class.
    this line :
    Regex Mon_Regex = new Regex("(([<][iI][mM][gG][^>]+)[sS][rR][cC][=][\"]{0,1}([^\"> ]*))");However, it works when I launch the applet in AppletViewer, but doesn't work anymore when I create a jar file, and open it through my web browser. (I signed already my jar file, and it works until it reaches this line). That it to say that the jvm can find the 2 external classes when I run the program trough Eclipse, but can't find them when I create my package .jar. (I hope I am clear)
    Do I need to extract the folders of this jar file ? Because I dont think the import works with those two classes. Or can I just put those 2 classes like my own classes, in this case, what to write for the import line ?
    the import I do :
    import com.stevesoft.pat.*;Thanks ^^

    I think I found a beginnig of solution, but I still have trouble.
    In the tutorial you gave me, it is said to add the following line in the manifest file to use jar in jar :
    Class-Path: JAR-FILE.jar(here is the source : http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html)
    I did it, it works fine locally, but when i put my html, jar, files on my web site, my applet seams not to find the other jar file again.
    Locally, the architecure is the following :
    \upload4.html
    \upload4.jar (its manifest have the class-path line linking with patbinfree153.jar)
    \patbinfree153.jar (contains 2 classes I need)I uploaded the same architecture on my web site, but it doesn't work. The applet stops when it reaches the 1st line where I need one of the patbinfree153 classes.
    Any idea ? :-)

  • How to handle 2 or more .jar files with an applet

    Hey out there
    I have created an ftpClient application that uses "jakarta ftpClient". It works fine as an JFrame application � But when I converted the Application into an JApplet I get the following Exception:
    java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
    I have bundled the main application into a .jar file (Application,jar). But I don't know how to handle the 2 jakarta .jar files with my JApplet??
    I Tried to append the 2 jakarta .jar files to the Application,jar with the following code:
    jar cvf Application.jar 1.class 2.class�. commons-net-1.4.1.jar jakarta-oro-2.0.8.jar
    But with the same result / Exception (I have signed the Jar file!)
    Can anyone help me

    Hi i have a question with your application can you down- or upload more files at the same time? Because i'm having problems with my ftp application.
    Here is the link with my problem maybe you can help me. I will be very pleased when you can help me.
    http://forum.java.sun.com/thread.jspa?threadID=5162042&tstart=0
    Thx
    Satanduvel

  • Getting Jar Files

    Hi,
    This is a very basic question. I would like to have J2SE 1.3.1 jar file so that I can include it into my classpath to use some classes such as java.util.Date version of this jar file. I would like to include in class path rather than installing J2SE 1.3.1 JVM on my computer.
    How can I do this?
    Thanks for your help in advance.
    Rohit

    You basically can't. There are native code programs that are needed too - that is what the JVM really is. It is a translation from Java code to native code. The jar file is only part of the JVM.

  • NOT WORKING: Putting a jar file requiring native library in bootclasspath

    Hi,
    I put my own jar file into the bootclasspath like this:
    java -Xbootclasspath/p:myboot.jar TestClass
    Some classes in the jar require a native library. For JVM 1.3 on Solaris, I put the native library in $JAVA_HOME/jre/lib/sparc and everything works just fine.
    However, when I try the same thing on JVM1.4, I got the following error when my class containing the native methods is called:
    Failed to load the native library: myboot_native
    java.lang.UnsatisfiedLinkError: no myboot_native in java.library.path
    I tried to put that native library in several different directories in jre/lib but still had no luck.
    Is there anybody know the solution? Does JVM1.4 allow me to put a custom jar file that requires a native library in the bootclasspath?
    Regards,
    Eman

    Well is your file in a directory included in the java.library.path environement variable. I use java on windows but I have to add the directory where my native library is to the path variable (not classpath) in order to avoid the error you get.

  • How to add a Jar file to J2EE Server Component Library ?

    Hello,
    My objective:
    =====================================================
    To add a 3rd party jar file to be a runtime jar file to J2EE Server Component
    Library project.
    I have created a J2EE Server Component Library project. 
    I have built the J2EE Server Component Library project to get the provider.xml file and place the provider.xml under the J2EE Server Component Library project's server folder.
    Here is my problem:
    =====================================================
    I can't open the provider.xml with SAP's special editor for the provider.xml.
    The special SAP editor doesn't exist for me.
    Here is my question:
    =====================================================
    Q1) Do I copy/paste my JAR_X file where <jar_0> is located? (Below is the
          J2EE Server Component Library SDA structure.)
    Q2) If you were to update the provider.xml with notepad, what would you
    type in provider.xml for JAR_X?
    Q3) Is there anything else that I need to do?
    Thanks,
    Steve
    J2EE Server Component Library SDA structure.
    ======================================
    |-META-INF_
    |         |-manifest.mf
    |         |-sap_manifest.mf
    |         |-SearchRules.xml
    |         |-<SDA>.xml
    |         |...
    |-<jar_0>
    |- ...
    |-<jar_N>
    |-dispatcher_
    |           |-provider.xml
    |           |-properties
    |           |-runtime.properties
    |           |-persistent__
    |           |            |-<persistent_files(2)>
    |           |-descriptors_
    |                        |-<descriptor_files(3)>
    |-server_____
    |           |-provider.xml
    |           |-properties
    |           |-runtime.properties
    |           |-persistent__
    |           |            |-<persistent_files>
    |           |-descriptors_
    |                        |-<descriptor_files>
    |-os_libs____
                |-<char set>__
                             |-<platform>__
                                          |-<jvm bitlength>__
                                                            |-<native lib files>

    Thank you for all your solution...
    my provider.xml was missing the <!DOCTYPE> tag for me to use the SAP LibraryDD Editor
    Thanks again,
    Steve
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE provider-descriptor SYSTEM "library.provider.dtd">
    <provider-descriptor>
         <display-name>
          Your_Lib_Name
        </display-name>
         <component-name>
          Your_Lib_Name
        </component-name>
         <major-version>6</major-version>
         <minor-version>40</minor-version>
         <micro-version>0</micro-version>
         <provider-name>
          sap.com
        </provider-name>
         <references>
              <reference
                   provider-name="sap.com"
                   strength="weak"
                   type="library">Your_Lib_Name</reference>
         </references>
         <jars>
              <jar-name>my_jar.jar</jar-name>
         </jars>
    </provider-descriptor>

  • Deploying an application with existing library as jar file created with ANT

    Hello All,
    I am having some trouble with a web application I am deploying to Tomcat. I have an custom library that works perfectly as a jar file included in the lib directory if I include all the jars that that library depends on into the lib directory also. What I would like to do is bundle the required jar files into my libraries jar file, but it failes to work when I do that.
    Any thoughts? Does Tomcat prevent this?
    I am using ANT to create my jar file, but when I look at the contents of my jar file it includes all the requested directories.
    My build.xml looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="myapp" basedir="." default="jar">
    <property name="classes.dir" value="./classes"/>
    <property name="jar.dir" value="."/>
    <property name="java_lib.dir" value="../../../../../Program Files/Java/lib"/>
    <target name="jar">
    <jar destfile="${jar.dir}/${ant.project.name}.jar">
    <fileset dir="classes"/>
    <fileset dir="${java_lib.dir}" includes="jai_codec.jar.jar"/>
    <fileset dir="${java_lib.dir}" includes="xercesImpl.jar"/>
    <fileset dir="${java_lib.dir}" includes="mysql-connector-java-3.1.8-bin.jar"/>
    <fileset dir="${java_lib.dir}" includes="xmlParserAPIs.jar"/>
    <fileset dir="${java_lib.dir}" includes="mlibwrapper_jai.jar"/>
    <fileset dir="${java_lib.dir}" includes="xml-apis.jar"/>
    <fileset dir="${java_lib.dir}" includes="jai_core.jar"/>
    </jar>
    </target>
    <target name="run" depends="jar">
    <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
    </target>
    <target name="clean-build" depends="jar"/>
    <target name="main" depends="run"/>
    </project>
    Like I said...it includes these jar files in my jar file, but will not function properly with my tomcat app. If I exclude these jar files and include them seperately then everything works.
    NOTE: I do not access any of these libraries directly from any servlets, only from my classes.
    Thanks,
    J-Rod

    This probably isn't posted on the correct forum. This JVM forum is for discussing issues related to running java in an Oracle database using the OJVM, Oracle's embedded java VM. Possibly you are trying to use OJVM through JDEV but that isn't clear from your post and I don't believe that the error you are reporting would occur in that case. If it did or if you are in fact trying to run client java via JDEV the problem would be a JDEV rather than OJVM issue and so the JDEV forum,
    JDeveloper and ADF
    is the correct one to use.

  • Reading Internationalised Bundles Outside of a Jar File

    I have seen this question many times throughout this forum and other forums where a jar file is tryingto load a resource outside of the jar file. The answers are often scattered or partial solutions. This is an attempt to provide a complete solution.
    Step 1)
    In your manifest file add to the Class-Path attribute the current directory, ie . plus any other library files you require (seperated with spaces).
    for example
    Class-Path: . lib/log4j.jar
    Step 2)
    In your code, make sure that you are correctly requesting the resource. If you are requesting a resource from the directory where you are running your jar file from (i.e. the working directory), simply use ResourceBundle.getBundle("Resource"); or equivalent method.
    If you bundle is within a directory, you must specify the directory when getting the Bundle as a dot seperated string, i.e.
    ResourceBundle.getBundle("etc.i18n.Resource"); would look for the file <working-directory)/etc/i18n/Resource.properties.
    I hope this may help people having problems with this excellent tool. Please feel free to add to this tutorial or amend any mistakes I may have made.
    Good Luck
    codemwnci

    I followed the instructions here and had every thing correct. I created the jar with ant using fearly standard build.xml. Things didn't still work out. Spent few hours wondering why things don't work.
    Reason: the property-files were not included in indexing.
    Basically there is two way around:
    1) Add the property files to the index of the jar.
    The problem here is that you cannot have new property-files without creating the index again.
    2) Don't do the indexing for the jar.
    In this case the jar is not so well optimazed, and in some case that may be a little problem.

  • How to create a java card library (jar file to be used in other programs)

    Hi all,
    I am working on JCOP and writing quite a bit of applets for the java card . Now i have lots of code that could be reusable for example sending SMS, encryption routine, etc.. So this part of the code i want to put into a utility class and create a package out of it. This utility package i must be able to import into my programs what i write.
    I tried the normal way of creating the jar by renaming the CAP file of the utility class, also tried including the /javacard/* files also into the jar file as indicated by sfarmer(active forum member here). But none seems to work. I tried contacting NXP folks and they indicated that it may be possible only by way of Sharable Objects.
    But some how i am not convinced why i should use Sharable object for this. So if any one can throw some light into this regard it will be immensely helpful to me and my project.
    Regards
    Prakash

    Hi,
    Well the variable defined are as below
    public static byte[] msgdata = new byte[255];
    private static final byte[] HEADER_TEMPLATE = {
              (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, // Command details tag
                   (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x02, // Device Identities tag
                   (byte) 0x8D, // Text String tag
                   (byte) 0x00, // length
                   (byte) 0x04, // Text String tag
    the msgdata is declared public so that i can access this as a Class member in my other program doing Utilities.msgdata. But the problem is now that if i dont declare it as final then the compiler gives me the below error
    "library has initialized array for non-final, non-static field Utilities, msgdata, [B, attr jc-field: tok 0, public static"
    If i make it final then i cannot change it... So now i am stuck..
    Any help will be highly appreciated...
    Regards
    Prakash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Download Error for apps from Creative Cloud desktop

    I have just signed up for the CS6 cloud package. As a teacher, I've paid for the Student or Teacher arrangement. However, I have not been able to download and install any of the applications. My first attempt was to download Acrobat from the website

  • Problem accessing applet methods since 1.4.2_06

    Hello, I'm working with ie 6.0 I'm accessing applet methods from javascript My applets were working fine until I installed the JRE 1.4.2_06 (I tested them with JRE 1.4.2_05 and it worked) Now, when I call an applet method from javascript, I have a ja

  • Passing default parameter to WebI for SAP BW cube

    Hi All, Data Source: SAP BW BI Layer: BO 3.1 Here goes my question: We have a cube which contains HR related data. I want to query data in such a way that it gets me data for the current month and year. The time dimension contains a hierarchy called

  • Help! IOS 7 wallpaper bug!

    Help! I was trying to set a picture as my wallpaper, but the iPad only let's me set 1 quarter of the picture as my background! Can anyone help fix this? Thanks! 

  • Error message 1001 on the Galaxy S5

    New to Verizon, I keep getting the error message 1001 when I try to use one of the Verizon apps, can anyone tell me what it is?