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?

Similar Messages

  • Dreamweaver cs4 or mx2004 may built .war or .jar files for deployment in a jsp server (Tomcat) ? If no, and use Dreamweaver  how do these files ?

    Dreamweaver cs4 or mx2004 may built .war or .jar files for deployment in a jsp server (Tomcat) ? If no, and use Dreamweaver  how do these files ?

    if I use Eclipse IDE for compilation[make *.war & *.jar files from *.java like claimBeans.java], I must use also Eclipse for upload/deploy ? Or for upload ONLY I may use and dreamweaver ? The jsp section of dreamweaver, is for app not require compilation, like from Code from:JSP STANDARD TAG LIBRARY , only ?
    Basically whatever I may do with "JavaBeans", "Servlets" etc (*.java files) needed to get compiled, I may also do it with JSP STANDARD TAG LIBRARY etc NOT NEEDED Compilation, so if I do not understand how to compile&deploy *.war & *.jar files , I may use instead the latter way ?

  • Include an in-memory jar file for JSR-199 compilation

    I want to compile a source file in memory, which requires a jar file that is also represented in memory. I used the JavaSourceFromString class recommended in the documentation for the class JavaCompiler and in a demo I found online that shows how to compile sources represented as String in memory. To represent the jar file, I used a similar trick to JavaSourceFromString:
    public class JarJavaFileObjectFromByteArray extends SimpleJavaFileObject {
       * The contents of this jar file.
      private final byte[] contents;
       * Constructs a new JarJavaFileObjectFromByteArray given the name and binary
       * contents of a jar file.
       * @param name the name of this jar file
       * @param contents the contents of this jar file
      public JarJavaFileObjectFromByteArray(String name, byte[] contents) {
        super(newURI(name), Kind.OTHER);
        this.contents = contents;
      ... // code not shown ensures that the URI returned from newURI is of the form,
          // for instance, bytes:///MathConstants.jar, if the name of the jar file is MathConstants.jar
      @Override
      public InputStream openInputStream() throws IOException {
        return new ByteArrayInputStream(contents);
    }However, I do not know how to alert the compiler that this jar file should be on the classpath. I tried this:
    List<String> options = Arrays.asList(" -classpath bytes:///MathConstants.jar ");
    CompilationTask task = compiler.getTask(null, fileManager, null, options, null, compilationUnits);but I get the following error when calling getTask:
    java.lang.IllegalArgumentException: invalid flag: -classpath bytes:///MathConstants.jarI assume there is some way to tell the compiler, "look at the MathConstants.jar file that I am storing in memory when searching the classpath", but I do not know how to do this. I assumed that the options parameter for getTask represents command-line flags that would be passed to the compiler if this were happening on the command line (such as "-cp .", which also does not work), but perhaps this assumption is wrong.

    Hi Bruce,
    I have a question regarding loading a jar file by the compiler to dynamically compile with a source file. I hope you can probably offer me an idea on what has been missing or wrong with the source codes I have written for my application.
    I am using Eclipse compiler to dynamically compile a class. In the class, I want it to make a reference to a jar file for compilation dynamically.
    Here is the source of a test class I wrote:
    import javax.servlet.http.HttpServlet;
    class MyServlet extends HttpServlet {
    }The import statement refers to the class javax.servlet.http.HttpServlet from the jar file C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar placed in the file system.
    In the method called compileClass (shown below), I used the path of the jar file to add to the option -classpath as you suggested.
         private static CompileClassResult compileClass(Writer out, String className, String classSource) {
              try {
                   JavaCompiler javac = new EclipseCompiler();
                   StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
                   SpecialClassLoader scl = new SpecialClassLoader();
                   SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);
                   List<String> options = new ArrayList<String>();
                   options.addAll(Arrays.asList("-classpath", "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
                   List<MemorySource> compilationUnits = Arrays.asList(new MemorySource(className, classSource));
                   DiagnosticListener<JavaFileObject> diagnosticListener = null;
                   Iterable<String> classes = null;
                   if (out == null) {
                        out = new PrintWriter(System.err);
                   JavaCompiler.CompilationTask compile = javac.getTask(out, fileManager, diagnosticListener, options, classes, compilationUnits);
                   boolean res = compile.call();
                   if (res) {
                        //Need to modify the api to return an array of two elements - one classes and other bytecodes for all classes in the same class file.
                        return CompileClassResult.newInstance(scl.findClasses(), scl.findByteCodes());
              } catch (Exception e) {
                   e.printStackTrace();               
              return null;
         }I also extended the class ForwardingJavaFileManager as you suggested and have it delegated to the StandardJavaFileManager sent to the compiler mentioned in the method compileClass above. The extended class (called SpecialJavaFileManager) is as follows:
    public class SpecialJavaFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
         private SpecialClassLoader xcl;
         public SpecialJavaFileManager(StandardJavaFileManager sjfm, SpecialClassLoader xcl) {
              super(sjfm);
              System.out.println("SpecialJavaFileManager");
              this.xcl = xcl;
         public JavaFileObject getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
              System.out.println("getJavaFileForOutput");
              MemoryByteCode mbc = new MemoryByteCode(name);
              xcl.addClass(name, mbc);
              return mbc;
         public Iterable<JavaFileObject> list(JavaFileManager.Location loc, String pkg, Set kinds, boolean recurse) throws IOException {
              System.out.println("list ");
            List<JavaFileObject> result = new ArrayList<JavaFileObject>();
            for (JavaFileObject f : super.list(loc, pkg, kinds, recurse)) {
                 System.out.println(f);
                result.add(f);
              return result;
    }I run the application and the result shows that it didn't load the jar file into the memory as expected. From the output (below) I got, it doesn't seem to invoke the method list(...) in the class SpecialJavaFileManager.
    SpecialJavaFileManager
    1. ERROR in \MyServlet.java (at line 1)
         import javax.servlet.http.*;
                ^^^^^^^^^^^^^
    The import javax.servlet cannot be resolved
    2. ERROR in \MyServlet.java (at line 3)
         class MyServlet extends HttpServlet {
                                 ^^^^^^^^^^^
    HttpServlet cannot be resolved to a typeWould you please let me know what has possibly be missing or wrong?
    Thanks.
    Jonathan
    Edited by: jonathanlam on Aug 10, 2009 6:47 PM

  • Help me out to get the jar files for FileUpload using MyFaces.

    hi,
    Can anyone help to get the jar files for FileUpload using MyFaces.
    I want myfaces-extensions.jar and commons-fileupload-1.0.jar.
    Thank you.

    you can't control the speed of a for-loop.
    you can remove your code from a for-loop and use a function to execute the code in your for-loop and you control how frequently you call the function.

  • 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().

  • 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

  • Can we make jar file for simple j2se application

    Hi..Can we make a jar file for simple j2se application so that it can be executed on any system like .exe file...

    Read the JAR files section in Sun's Java tutorial.

  • Can't able to access the Jar files which is kept inside the folder.

    Hi,
    I am using the eclipse IDE, my project folder contains the folders src, bin, .metadata, .settings
    if i place the jar file in the same location of the above mentioned folder means i can able to use the Jar file in eclipse(in my project).
    But i create one folder in the same location in the name of Jar or anything and all jar files are placed inside the folder,then i can't able to access the jar file in eclipse(in my project).
    How i can solve this problem?

    RajivGuna wrote:
    ..How i can solve this problem?Put Eclipse aside for the moment and learn how the SDK tools work at the level of the command line, then you will be much better placed to figure how to do it in the IDE. If you are still having problems, I suggest you ask on an [Eclipse forum|http://www.eclipse.org/forums/].

  • Can anybody provide type 4 jar file for oracle 9i + jdk 1.5

    Hello,
    I want to connect my java application(jdk 1.5) to oracle.Can any body provide the jar file for that one and whre I want to put that jar file.Please send me one sample code for jdbc connection to oracle for calling a stored procedure in oracle.
    Bipin.V

    Wouldn't it be easier to google on e.g. oracle jdbc download?
    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
    Kaj

  • Cannot make executable jar file for swt application

    hi to all!!! i have started learning swt library and it seems nice to me, but i have one problem, i cannot run my application. The problem is that i cannot make executable jar for it.
    i'm using ecilpse_3.1.2 and have pluggined the visual editor for swt! yesterday i found one topic where was described the process of making the swt executable jar, i followed the instructions in the topic, but didn't resolve my problem, so if anybody knows how to achieve this , please help!!!!!!
    the instructions in the mentioned topic are :
    1. Make sure the SWT jar file is included in the Eclipse project build path
    a. Download the standalone SWT jar file from eclipse.org even if you already have the ones that come with Eclipse. It is called ?swt.jar? and you will package it with the executable JAR. Make sure it is the same version of SWT that you used to make your program.
    b. In Eclipse, import swt.jar via Project Properties::Java Build Path::Libraries::Add External JARs. (Make sure to include the source .zip file). Also make sure to select the swt package in the ?Order and Export? tab.
    c. At this point, you should be able to compile and run your SWT application in the Eclipse SDK.
    2. Do a standard Eclipse jar file export
    a. Right click on the main .java project file and select ?Export??.
    b. Choose ?JAR File? from the list.
    c. Select the relevant packages and .classpath and .project resource files
    d. Make sure ?Export generated class files and resources? is selected and browse to the location where you want the JAR file to be created.
    e. Specify ?Generate the manifest file? and don?t seal the JAR or any packages. Choose the class containing the main method as the ?Main class?.
    3. Change the manifest file
    a. Navigate to the JAR file you created and open it with WinZip.
    b. Open the MANIFEST.MF file inside and copy the contents.
    c. Create a new file called ?MANIFEST.MF? and paste in the contents of the old manifest file.
    d. Add the line ?Class-Path: <swt jar file path>?. For simplicity, you can just keep a copy of the swt.jar file in the same folder as the executable jar, in which case, the line is ?Class-Path: swt.jar?. Make sure there is a carriage return after the last line in the manifest file, or that line will not be parsed.
    4. Replace the manifest file
    a. Make sure the manifest file and the executable jar are in the same folder.
    b. Open the command prompt and navigate to the containing folder.
    c. Enter the command ?jar umf MANIFEST.MF <executable jar name>? to update the manifest file with the class path information.
    5. Package the JAR with SWT files
    a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like ?swt-win32-####.dll? on Windows.
    b. The JAR file should now successfully execute. On Windows, you can usually just double click the JAR file in explorer and it will open. If that does not work, the command ?java ?jar <executable jar name>? on the command line has the same effect.
    but a few steps aren't exact for me , for example : first, which jar i have to include in build path : downloaded or from plugins folder, second
    i have to incude source.zip too??? but it is only in downloaded zip file which includes both swt.jar and src.zip, and finally can anyone clarify next :
    "5. Package the JAR with SWT files
    a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like ?swt-win32-####.dll? on Windows."
    what does this mean, put these in folder or make jar from them????

    wolve634 wrote:
    but a few steps aren't exact for me , for example : first, which jar i have to include in build path : downloaded or from plugins folder, secondTry it both ways. If neither works, then ask again. In a suitable forum, though. An Eclipse forum or an SWT forum or something related to where you got those instructions would make a lot more sense than asking here.
    i have to incude source.zip too???No, of course you don't have to distribute the source code.
    a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like ?swt-win32-####.dll? on Windows."
    what does this mean, put these in folder or make jar from them????It says "Put (them) in the same folder". You're asking whether that means to put them in a folder? Yes, it does.

  • Help! How to create Jar file for a packaged class?

    Hi!
    I am new in jar complexities. I made a swing frame that just prompts a JOptionPane when executed. I accomplished the same using jar without packaging my class SwingTest.
    But when i package it, it doesn't run. Can any one tell me how to make jar file of packaged classes and include images in the jar files too!
    Really Thanx!

    Call the Jar from the commandline to see the exceptions thrown.
    java -jar <jarFileName> <className>

  • Jar file for com.bea.xbean.util.XsTypeConverter

    I am using weblogic 10.3.5 I used clientgen to generate java classes for a webservice and a few classes are using the class XsTypeConverter.
    I have imported weblogic.jar but it says package does not exist com.bea.xbean.util.XsTypeConverter.
    Where can i find the jar file for this under weblogic?
    Thanks,

    Thank you so much for the reply.I have included all the jars you suggested.I could not find wlfulclient.jar in my weblogic home but there was
    wlclient.jar so I included that but face the same error.
    I used weblogic 10.3.5 clientgen to geberate the java classes then why is it that the classes it uses cannot be found in the same version.
    where jar will have the file com.bea.xbean.util.XsTypeConverter.
    I have searched a lot on internet but not able to find anything.Please help

  • Problem while creating JAR file for my swing application

    Hi...
    Using my swings application I am trying to Run different software�s .
    My program is Running fine from command prompt. If I create JAR file
    It is giving error like �Failed to load Main-Class manifest attribute from .jar�
    Can anybody help me to creating JAR file
    Thanks in advance
    Cheers
    Mallik

    hi,
    User following command
    jar-cmf textfile_name.txt Jarfile_name *
    here you have to make manifest file
    and making jar file you have reach there by command promt
    and manifest file have some constraint also as well as format
    format are
    Manifest-Version: 1.0
    Class-path: jar file name which are using in app separed by space
    Created-By: 1.5.0 (Sun Microsystems Inc.)
    Main-Class: Main class name
    and end of file is not have carriage return

  • How to make .jar file for a multiple class program

    I have a code for a chat room that contains two folders , one for Server and one for Client
    What I need is to create a jar file for the server and a jar file for the clients
    but here the first problem , I have a file that named (SocketMessengerConstants.class) that is located outside the two folders and is being read by the two projects .
    I mean the server uses it while running and the client uses it too .
    the second problem is : I don't know how to create a jar file at all !
    please tell me how to do it in detail
    Thank you

    ChuckBing wrote:[Packaging Programs in JAR Files|http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    I tried to read this tutorials before I come here but I couldn't understand it
    can you please tell me a specific steps to follow instead of the explaining .. because I understand the explanation but I can't apply it

  • How to create a .jar file for the BPEL project

    hi all,
    how can i create a .jar file for my BPEL project, i am trying to deploy the project but getting an error :
    "Error: [Error ORABPEL-10902]: compilation failed [Description]: in "C:\OraBPELPM\integration\jdev\jdev\mywork\Workspace_BPELDemo\BPEL_Report\BPEL_Report.bpel", XML parsing failed because "". [Potential fix]: n/a. "
    and when doubel cliking on this error Jdev take me to the beginning of the ".bpel" file.
    I 'm really stuck in here i am not able to deploy the process!
    Thanks,
    Rana

    Rana:
    If you haven't already, I would post this question in the BPEL forum. I would expect a much better turnaround there.
    Johnny Lee

Maybe you are looking for