A .dll inside a .jar file

Hello,
I want to place a .dll inside a .jar file ? It's possible, What is the library.path setting: the jar file or the path where the dll is put is in the jar file; and the argument of the System.loadLibrary?
Thank for all

Hello,
I want to place a .dll inside a .jar file ? It's
possible,Of course, you can put any type of file you want into a jar file.
What is the library.path setting: the jar
file or the path where the dll is put is in the jar
file; and the argument of the System.loadLibrary?You cannot do a System.load() or System.loadLibrary() on something in a jar file.
You have to first extract the dll to the filesystem. Then if you put it in the library path you can use System.loadLibrary(). But I think it is easier to use System.load() as you know the complete path to where you put the dll and can just supply that to System.load().

Similar Messages

  • To add the JNI dll to the jar file and use the dll inside the jar file

    Hi to everybody,
    I am new to java.
    I want to add the JNI dll to the jar file and use it in the java class.
    How can I achieve it.
    Please help me.
    Thanks in advance.
    Regards,
    M.Sivadhas.

    can't be done because none of the known operating systems support reading binary libraries from .jar files ... you can add the binary to the jar but then you have to extract it...
    besides, mixing platform specific and platfrom independent components is not a very good idea, i'd keep the dll out of the jar to begin with

  • How can i get the path to config folder placed inside the jar file?

    Hi i have developed an RCP application using eclipse.
    In my application config directory is there.
    When i export my RCP application as JNLP Project the jar file is created which contains config folder inside it.
    When i download the application using java web start , how can i get the path to config folder placed inside the jar file?
    Will the config folder exists in local cache in my system?
    Help needed.
    -Deepak

    -- This works in CS6:
    tell application "Adobe InDesign CS6"
      set myDocument to active document
      set selectedRectangles to selection of myDocument
      set theGraphicsLink to file path of item link of (graphic 1 of (item 1 of selectedRectangles))
    --> "Macintosh HD:folder/folder/filename.tif"
    end tell

  • Call class inside a jar file??

    Hello group,
    I have a class with a main mathod and this class is inside a .jar file. This jar file reside under my
    web-inf\lib or class-path directory in my application at Weblogic Server.
    How can I call this class by command line?
    I have to create a cliente to do it?
    Is it possible? I´m having problems because the weblogic server is using the jar file at the same time that I trying use it calling by command line.
    Where can I find more information?
    Message was edited by:
    Denimar

    Authcloud9981 wrote:
    Hi I have an executible JAR file that I can call from command line by using the command - "java -jar file.jar".
    Is there a way for me to call this JAR file inside a Java class in another Java Program?There can be more going on in a jar than just as a container for classes.
    The manifest defines the behavior. So to replicate the behavior you must do exactly that.
    As an example of that.
    [http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html#download]
    Additionally by running it in your application you must consider what the scope of that is. If you just load the classes directly then they will be in the system class loader and thus cannot be unloaded. Using a class loader solves that.

  • Include and call an .exe file inside my jar file

    Hi.
    I want to include an exe file and call it inside my jar file. this is the code.
    InputStream is = getClass().getResourceAsStream("/native/my.exe");
              int[] line = new int[is.available()];
              File myFile = File.createTempFile("my","exe");
              myFile.deleteOnExit();
              myFile.setExecutable(true);
              FileOutputStream out = new FileOutputStream(myFile.getAbsolutePath());
              int i = 0;
              int c;
              while((c=is.read()) != -1){
                   line=c;
                   i++;
              is.close();
              for(int j= 0;j<line.length;j++)
                   out.write(line[j]);
              out.close();
    So i store it in my temp folder. Than i run
    String myFileLocation = myFile.getAbsolutePath();
    p = rt.exec(myFileLocation);
    Everything goes fine, but the behaviour of the .exe file is not the same. I mean when i run the commands
    PrintWriter writer = new PrintWriter(p.getoutputStream());
    writer.println("command");
    the behaviour is not the same. What goes wrong.

    But to load the xml file I need to create a File objectIf this is true then you will not be able to load the XML file, since a jar entry is not a File object and cannot be represented as one.
    However if you get rid of whatever it is that loads your XML file and replace it by more standard JAXP processing, you should be able to parse an InputStream that reads from the jar entry. You know how to get that so it should not be a problem.

  • Java Files inside the jar file cannot be read or accessed through Eclpse

    The Java File inside the jar file of the eclipse cannot be accessed through the Eclipse . It shows error for the modules in the jar file .
    But when compiled with adding the jar files to the class path the compilation is successful .
    How can i browse through the files in the jar like going into the function definition .
    TIA ,
    Imran

    Open MPlayer OSX and show the playlist (command-shift-p) then drag the file into the playlist. Click the file in the playlist and click the "i"nfo button. What does it list for file, video and audio format?
    Not all of the codecs used in avi and wmv files are available for OS X so I'm guessing your file happens to be using one that isn't...

  • I am having Html help files inside my Jar file

    Dear Friends;
    i am having Html help files inside my Jar file.
    how will open the html file using Java Help.
    Thank u

    http://java.sun.com/products/javahelp/reference/docs/index.html

  • Can i load a class in subdirectoy  inside a jar file using applet tag?

    hi every one.. thank you for reading ... i am really in dire need for the solution..
    my problem is that i have a jar file contianing a package which inturn contains my applet class...
    i am trying to access this applet class using a applet tag in html file. this html file is in same directory as the jar file. i am having no problems in windows but when i am doing this in linux apache server i was getting class not found exception. (already checked the file permissions). and when i am successful when using simple package directory instead of jar file . so gist of my quesition is "can i load a class in subdirectoy inside a jar file using applet tag in a html file"?

    When you tested in Windows were you using Internet Explorer? On Linux you will be using a different browser, usually Mozilla of some version, or Firefox. Note that the HTML tags for applets will be different between the browsers if you are using the object tag. Principally the classid value for the object tag will differ between Firefox and Internet Explorer.

  • How to read, write file inside the JAR file?

    Hi all,
    I want to read the file inside the jar file, use following method:
    File file = new File("filename");
    It works if not in JAR file, but it doesn't work if it's in a JAR file.
    I found someone had the same problem, but no reply.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
    Can you help me ? I have tried this for all night !
    Thanks in advance
    Leo

    If you want to read a file from the JAR file that the
    application is packaged in (rather than a separate
    external JAR file) you do it like this ...
    InputStream is =
    ClassLoader.getSystemResourceAsStream("filename");Better to use
    this.getClass().getClassLoader().getResourceAsStream();
    From a class near to where the data is. This deals with multiple classloaders properly.

  • Can I include dlls in a jar file for deployment?

    I have a set of dll's I need to deploy (some kind of database driver needed along with my java application) in a client/server situation. Instead of copying these dll's to the client's system32 folder on windows, can I simply include these dll's in the jar file containing my java applications?

    No it was just to make everything cleaner. But if I have to take them outside of the jar file, then like you say there's no benefit in putting them in there in the first place.
    As for having the dll's in the same directory or a sub directory, how can I load them then? Using the function System.loadLibrary?

  • How to read a file inside the JAR file

    Hi All,
    I want to save some preferences in a file called "preferences". I kept the preferences file under my java package.
    If i am running the code inside the NetBeans 6.9 IDE it's working file. But once i have created a JAR and try to run the application, it couldn't find the path.
    Please help me that how to resolve this issue. I don't want to save this preferences file outside of my JAR (i.e) within my java package.
    Here is the code,
    package mypackage;
    import java.io.BufferedReader;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    public class ReadFile
        private void writeFile()
            try
                OutputStream out = new FileOutputStream(getClass().getClassLoader().getResource("mypackage/preferences").getPath().replace("%20", " "));
                PrintWriter writer = new PrintWriter(out);
                writer.println("Hello Java!");
                writer.close();
                out.close();
            catch (Exception ex)
                System.out.println(ex.getMessage());
        private void readFile()
            try
                FileInputStream fi = new FileInputStream(getClass().getClassLoader().getResource("mypackage/preferences").getPath().replace("%20", " "));
                BufferedReader br = new BufferedReader(new InputStreamReader(fi));
                System.out.println(br.readLine().trim());
                br.close();
                fi.close();
            catch (Exception ex)
                System.out.println(ex.getMessage());
        public static void main(String[] args)
            ReadFile read = new ReadFile();
            read.writeFile();
            read.readFile();
    }If i run the JAR, i get the following error message,
    {color:#ff0000}*file:\my jar path\jarname.jar!\mypackage\preferences (The filename, directoryname, or volume label syntax is incorrect)*{color}

    Thanks sabre150,
    sabre150 wrote:
    You cannot update a running jar file. I am sorry. I didn't know about it. Thanks to point out.
    There are two ways I approach this depending on my exact requirements -
    1) use the java.util.prefs.Preferences APII will try this one
    >
    2) if not already present I copy the preferences file from the jar to a known place. I use a directory in the user's home directory and normally make the directory name the program with a '.' prefix.
    One cannot access files in a jar file using the File API. One needs to use the getResource() or getResourceAsStream() methods on Class or ClassLoader.

  • How do i run a file that is inside a jar file?

    Hi all,
    Here's what I'm trying to do: on a Unix (Solaris) box, I have a shell script bundled in with my application in a jar file. All I want to do is run the shell script from inside my java app, but I'm having trouble doing so.
    If i try the following code:
    Process process = Runtime.getRuntime().exec("myproject/tools/scripts/myscript.sh");
    int exitVal = process.waitFor();I get the following error:
    java.io.IOException: myproject/tools/scripts/myscripts.sh: not found
            at java.lang.UNIXProcess.forkAndExec(Native Method)
            at java.lang.UNIXProcess.<init>(UNIXProcess.java:52)
            at java.lang.Runtime.execInternal(Native Method)So then I did some searching and tried something like :
         ClassLoader cl = this.getClass().getClassLoader();
         URL the_file = cl.getResource("myproject/tools/scripts/myscript.sh");
         Process process = Runtime.getRuntime().exec(the_file);
         int exitVal = process.waitFor();but i get this error:
    cannot resolve symbol
    symbol  : method exec (java.net.URL)
    location: class java.lang.Runtime
         Process process = Runtime.getRuntime().exec(the_file);So is that the right way i should be doing this? Should i convert the URL (the_file)
    to something else before passing to exec()?
    Any hints/help/suggestions would be greatly appreciated.
    Thanks.

    The trouble with your first attempt might be that your relative path to the shell script is not relative to where you think it is. You could try again with an absolute path to the script as a simple test. Assuming that works you can try a more permanent solution -- perhaps a startup script for the Java app that defines a base path or a Properties file.
    You are exactly right about the problem with your second try. The exec method in all its forms expects a String as the first argument, so the URL is not going to help much, assuming that the URL is in fact non-null.

  • Extracting and updating files inside a JAR file... from my code

    Hi.
    I need some help in the following:
    from my code, I need to search a JAR file, open it, unzipped it, then I need to search a xml and property files inside the JAR, after that I need to modify the files and finally, my code has to save the changes and update the JAR file. All that must be from my java code.
    How can I do that? I am trying to use Runtime.getRunTime().exec().... but I am not sure that it works. Besides, I don�t know what command to include in the exec() method. Is there any way to do that?
    Thanks

    The normal reason I see for this requirement is that people want to update a properties or data file. The approach I use it that I first look for the data file in a well defined location and if I find it I use it and update it as required. If I don't fine it I create it base on a template file read from the jar file using getResourceAsSrream().
    In this way I never have to update the jar file.

  • Classpath inside a JAR file...

    Hi there,
    I have recently learned that I cannot use my JDBC driver JAR file from within another JAR file. So now I have two JAR files........my application and associated files in one and the JDBC driver in the other.
    This gives me......
    gatekeeper.jar
    ojdbc14.jar
    My problem is, when running the application I get an exception stating that it cannot load the Oracle driver. I'm assuming that this is because it cannot find the JDBC JAR file from within the manifest Class-Path.
    My manifest is this: -
    Main-Class: GateKeeper
    Class-Path: ojdbc14.jar commonfiles images
    This includes my commonfiles package (all classes) and my images directory. All these things are included. I'm trying to run the gatekeeper JAR file from the same directory as the JDBC driver JAR file.
    I've tried: -
    Class-Path: ojdbc14.jar commonfiles images
    Class-Path: .\ojdbc14.jar commonfiles images
    Class-Path: ..\ojdbc14.jar commonfiles images
    None of these things help. Obviously I could just specify the JDBC JAR file when running the application using: -
    java -cp ojdbc14.jar -jar gatekeeper.jar
    ....but I want to have the user just run it without having to know about the classpath.....i.e.
    java -jar gatekeeper.jar
    DrClap said (and I quote) "In the same directory as your main JAR file is easiest, but at any rate the Class-Path entry in your manifest should include the relative path of the driver jar."
    ...Isn't the relative path to the JAR file outside the JAR this?
    .\ojdbc14.jar
    Basically, to recap....from within my JAR application file I want to add to the classpath in the manifest file the JAR file that is outside the application JAR file in the same directory. Helpy?
    ...I'd offer dukes to you fine folks, but I've only got two left. Since I'm such a newbie, I'm not likely to get any more inthe near future, so I'm saving them for a raining day. :) I hope I can get a little charity without resorting to duke bribary. :)

    Hmmm...still not joy. This is the exception I'm getting with the stacktrace.
    C:\Java\deployment\GateKeeper\JarFile>C:\j2sdk1.4.2_03\bin\java -jar gatekeeper.jar
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
    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)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at commonfiles.OracleDataConnection.<init>(OracleDataConnection.java:26)
    at GateKeeperFrame$MainAction.actionPerformed(GateKeeperFrame.java:429)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
    at java.awt.Component.processMouseEvent(Component.java:5100)
    at java.awt.Component.processEvent(Component.java:4897)
    at java.awt.Container.processEvent(Container.java:1569)
    at java.awt.Component.dispatchEventImpl(Component.java:3615)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
    at java.awt.Container.dispatchEventImpl(Container.java:1613)
    at java.awt.Window.dispatchEventImpl(Window.java:1606)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    My gatekeeper.jar file contains the following files: -
    C:\Java\deployment\GateKeeper\JarFile>jar -tvf gatekeeper.jar
    0 Wed May 19 19:06:42 BST 2004 META-INF/
    95 Wed May 19 19:06:42 BST 2004 META-INF/MANIFEST.MF
    0 Wed May 19 19:06:38 BST 2004 commonfiles/
    1185 Mon Apr 26 22:24:30 BST 2004 commonfiles/ErrorDialog.class
    1319 Fri Apr 16 10:50:28 BST 2004 commonfiles/ErrorItem.class
    1381 Tue Apr 27 19:53:32 BST 2004 commonfiles/ErrorList.class
    4207 Mon May 17 12:58:40 BST 2004 commonfiles/FileIO.class
    1371 Fri May 14 12:00:38 BST 2004 commonfiles/Input.class
    1655 Fri Apr 23 15:13:58 BST 2004 commonfiles/OracleConnectionDetails.class
    6653 Fri May 14 14:34:58 BST 2004 commonfiles/OracleDataConnection.class
    8612 Fri May 14 15:06:02 BST 2004 commonfiles/Utility.class
    0 Mon May 17 19:56:40 BST 2004 images/
    116 Wed Apr 21 10:19:50 BST 2004 images/Connect.gif
    119 Wed Apr 21 10:19:28 BST 2004 images/Disconnect.gif
    117 Wed Apr 21 10:16:24 BST 2004 images/Exit.gif
    1024 Mon May 10 14:38:28 BST 2004 GateKeeper.class
    186 Wed May 12 11:08:44 BST 2004 GateKeeperFrame$1.class
    5300 Mon May 17 14:38:28 BST 2004 GateKeeperFrame$MainAction.class
    1740 Fri May 14 15:21:20 BST 2004 GateKeeperFrame$MainButtonListener.class
    11034 Mon May 17 11:07:30 BST 2004 GateKeeperFrame.class
    898 Wed Apr 28 22:10:56 BST 2004 LoginFrame$DataSource.class
    6938 Wed Apr 28 22:10:56 BST 2004 LoginFrame.class
    3261 Fri May 14 12:22:28 BST 2004 UsersDataModel.class
    My manifest file for gatekeeper.jar file contains this: -
    Main-Class: GateKeeper
    Class-Path: ojdbc14.jar
    And the directory where I'm running the gatekeeper.jar file contains this: -
    gatekeeper.jar
    ojdbc14.jar
    which I'm running using: -
    java -jar gatekeeper.jar
    Thanks for your help guys. And no, I don't have a newline at the end of the Class-Path entry in the manifest.

  • How do I jar with the full package info inside the jar file?

    I want to jar so the jar tvf shows
    dir.path.x.y.z.filename.class, or
    dir\path\x\y\z\filename.class
    What is the command for this? Thanks

    Got it, see also
    http://forum.java.sun.com/thread.jsp?forum=31&thread=351405
    1. Go to higher path
    2. jar TargetJarName.jar dir.tree.x.y.z\*.class
    3. java -classpath dir.tree.x.y.z -jar TargetJarName.jar <arg>
    BTW, dir.tree.x.y.z excludes a.b.c where full DOS path =
    a.b.c.dir.tree.x.y.z

Maybe you are looking for