Including exe in a jar

hi,
i want to include a .exe in a jar,how do i di it..actualy what my code does is that it calls a exe from inside which i have saved somewhere else..what i want is to get this exe included in jar so that i wil not have to save it newhere else..is it possible..
plz try help..

I would reply to that but I'll just stick with what
you gave me..... thx for replying anyway, at a first
look it seems as if I didn't specify the search
pattern anough to get a good score when seraching....
well thx for replyingDon't take it personally, this question has just been answered many times lately. I didn't feel like doing it again.

Similar Messages

  • Executing an file.exe from a jar file?

    Does anyone know how to execute an *.exe file from jar file?
    I have two files that I want to execute in one java.class, Monview.exe and Moninit.exe. Both are stored in the same jar file as the class called link.class.
    This is my code to run one of the files from the hard drive
    String []cmd={"c:\\monview.exe"};
    try
    Process pr = Runtime.getRuntime().exec(cmd);
    StringBuffer buf = new StringBuffer();
    InputStream istr = pr.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(istr));
    String str;
    while ((str = br.readLine()) != null) {      
                             buf.append(str);
    try {       
    pr.waitFor();
    } catch (InterruptedException e) { }
         if (pr.exitValue() != 0) {      
         br.close();
    catch (IOException e){}
    It works when i place both .exe on the local host harddrive but when I place it in the jar file nothing happens. Could anyone help me please on why does this happen and how I can fix it? Or on how to get the link.class code to extract it from the jar file and place it on the system directory and delete it from the system directory, without it knowing where the jar file comes from?

    Hello,
    If I am not mistaken, by including the JAR file in the CLASSPATH (specifying the absolute path), or after the -classpath option after the java command (java -classpath jar_archive main_class), the system will find both files in the JAR archive.
    Hope this helps!

  • [svn] 3140: Modifying build. xml to include templates in the jar from the new location.

    Revision: 3140
    Author: [email protected]
    Date: 2008-09-08 09:04:17 -0700 (Mon, 08 Sep 2008)
    Log Message:
    Modifying build.xml to include templates in the jar from the new location.
    Modified Paths:
    flex/sdk/trunk/modules/antTasks/build.xml

    Don't be so impatient and don't multipost! I've deleted your other thread about the same topic.

  • How to include and call exe file in jar?

    Hi, I am writing a Java application that calls an external exe file to accomplish some tasks. In order to make the program more user friendly, I would like to package the Java application and the exe file into one JAR file and distribute that JAR file to users. I tried to package all these files by running the following command:
    jar cmf manifest.txt java_class_file exe_fileThe manifest.txt contains only the following entry:
    Main-Class: java_class_fileHowever, when I execute the program with java -jar bundle.jar, the JVM complains that it cannot find the exe file. (Everything works fine when I run the original class file with java)
    Would anyone kindly teach me how to do this?
    Thanks in advance!

    You cannot call an exe file in a jar.
    You can have the jar unpack the exe and then run it however.

  • 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 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

  • How to include grouplayout in my .jar file.

    Hello,
    I have a program that works great on my comptuer and the one in my lab. I would like to deploy this .jar file to other systems, but these other systems are only running JRE 1.5.0_10-b03. The problem, as I understand it, is that swing.grouplayout first appeared in JRE1.6.XX so these older versions don't have the proper librairies to run this.
    How do I include the grouplayout class with my .jar file. I have searched all over my HDD and cannot find the grouplayout class file to include. Am I on the right track?
    Thanks!
    -- Snow

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • Running exe contained in jar file

    Hello,
    I have written a java interface where an external executable is being called from one of the classes. I'm using Jgrasp as development environment.
    Everything works fine if I run the java program from within Jgrasp: the interface opens up fine and it can run the external program when the button which is supposed to start it is clicked on.
    I have then generated a JAR file containing all the classes etc and also the external executable.
    When I execute the Jar file, the interface opens up ok and everything works fine within it, but it cannot run the external executable any more.
    Is it possible to run an exe file contained in the jar file itself?
    I would like to distribute a single jar file containing all the files needed by the application.
    Thanks

    An EXE can only be executed from Java if it resides somewhere in the file system.
    This is obviously the case before you JAR the whole thing, but not after.
    Your code will need to extract the EXE by using Class.getResourceAsStream() and
    copy it to a temporary location in the file system before executing it.

  • Exec exe file in jar

    Hi,
    Is there a way to execute an exe file that is inside the jar with the main class?
    Right now, I am copying the file to a folder, and executing it.
    Thanks

    Would be a great security risk...
    Not possible.

  • Including libraries in executable jar

    Hi,
    jdeveloper 11.1.1.3 here. I have wrote a one-class application, which uses the jdbc oracle driver to connect to a database. I want to make an executable jar of this application. I have succesfully imported the driver in my jar file, but in the manifest file, no classpath entries are added, making the application cast a classnotfound exception on startup.
    I followed this tutorial http://blogs.oracle.com/olaf/2008/01/
    and this thread jdev and jar file
    but they didn't work for me.
    what should i look at?
    Thanks in advance

    You have to make the entries in the manifest file yourself. JDev will not do it automatically. Create a file (e.g. mymanifest.mf) and include it in your deployment profile in the manifest section.
    In This file you enter the needed jars like:
    Class-Path: ./lib/ojdbc14dms.jar ./lib/dms.jar ./lib/ocrs12.jar ./lib/ojdl.jar ./lib/orai18n.jar
    Save the file and deploy the jar.
    Timo

  • Including a DLL in JAR file (Comm API)

    Writing a little app that interfaces with serial port device using the communications API and I'd like to bundle it into an executable JAR. JBuilder will create the JAR for me fine, but the issue is with the win32com.dll file thats part of the comms API. I need to include this, I don't think its possible to include as part of the executable, but otherwise the DLL needs to be in the windows\system folder. Could I include the dll as part of the JAR archive and then extract it upon runtime? If so how would I go about this?
    Any help much appreciated.

    There is another option. Native libraries need to reside within the java.library.path location. As it turns out, if you, at runtime, grab this property and ADD your own location to it, then set it back in to the System.setProperty() call, it will NOT work. The only way to do it is the -Djava.library.path value that tjmaven suggested.
    However, if you read up on how a native library is found, it uses the ClassLoader.loadLibrary() which calls the protected findLibrary() method. You can therefore extend ClassLoader to find a path yourself.
    One way is to extend URLClassLoader since it has the protection/security stuff AND the ability to look in .jar files for you. Your custom loader is created by a "launcher" class in your .jar file. First, your luancher uses getClass().getProtectionDomain().getCodeSource().getLocation() to get the absolute location of the .jar file its executing within. From there, you open the jar and look for your native library, extract it using the JAR api to a location of your choosing. Now, you instantiate the custom classloader and using this custom loader instance you load the rest of your classes. The main .jar file contains two classes, the launcher and the custom classloader, and contains the native library if you wish to do it this way. The custom classloader, you specify a URL[] of "classpath" entries. You bundle up the rest of your source in a second .jar file that you pass to the URL[] when creating the custom classloader. It will find all your classes in the 2nd jar no sweat. You can even "reload" these classes on the fly by recreating the custom classloader instance if you so wish to add a sort of "reload" feature.
    Now, in your custom classloader, you override the findLibrary() and return the SAME STRING PATH that you used to unjar your native files to. This way, when the JVM asks your custom loader to load the library at some path, you return the right path to find the native files in.
    I haven't verified that this works just yet, but I will soon. Primarily, my plugin engine over at www.platonos.org will support the ability to place native libraries in plugins, allowing you to effectively wrap a native library use as a plugin. Not yet working, but we'll soon have it in place.

  • Including large number of jars in classpath...

    Hello,
    I have an application that relies on over 100 jars and a set of classes - I have been using an IDE to set the classpath so far, which has been fine, but I need to distribute the application to others, and so need to bundle the classes, preferably as a jar. I have tried multiple variations of setting the classpath within the manifest for the jar file (that includes only my source), and have finally resorted to setting the classpath using a batch file and running directly using the classes. Neither method works - the classpath seems to be too long - the best results I've got are with the bat file, but this loads all but the last 8 jars - taking out a few jars adds one or two more, so this seems to confirm a maximum length for the classpath. (FYI, I have previously used the manifest to set the classpath and this has been fine, but in this case I had only two jars.)
    Has anyone come across this problem, and if so, have you managed to find a solution - I've combed through the relevant postings to this forum and have found similar problems but no actual Manifest or bat file example apart from a description of what was done, all of which I've tried, and none of which worked. The option to use the wildcard * in the classpath environment variable doesn't work because I cannot use JDK1.6 - the external libraries need to run on JDK1.5 - I have actually tried this but it is not expanded.
    Aba-Sah

    Another option is to package (or "flatten") all the dependencies into a single JAR. I use the following Groovy script in ANT builds to copy files from many JARs to a single location ...
    <!-- set up a groovy task -->
    <taskdef name="groovy"
              classname="org.codehaus.groovy.ant.Groovy"
         classpathref="compile-cp"/>
    <!-- you'll need to adapt this to your environment -->
    <target name="flattenLibs">
              <mkdir dir="${dist-temp}"/>
              <groovy>
                   import java.io.*;
                   import java.util.zip.*;
                   import java.util.jar.*;
                   def copyBinary(isDir, dfile, is) {
                        def file = new File( dfile )
                        if ( isDir ) {
                             file.mkdirs()
                        else {
                             def preIndex = Math.max( dfile.lastIndexOf( "/" ), dfile.lastIndexOf( "\\" ) )
                             if ( preIndex > 0 )
                                  new File( dfile.substring( 0, preIndex + 1 ) ).mkdirs()
                             def fout = new BufferedOutputStream( new FileOutputStream( file ) )
                             try {
                                  byte[] buffer = new byte[ 1024 ]
                                  int i
                                  while ( ( i = is.read( buffer, 0, buffer.length ) ) > 0 )
                                       fout.write( buffer, 0, i )
                                  fout.close()
                             finally {
                                  fout.close()
                   def destDir = project.getProperty( "dist-temp" )
                   if ( destDir.endsWith( "\\" ) || destDir.endsWith( "/" ) )
                        destDir = destDir.subString( 0, destDir.length() - 1 )
                   // Look at "core-cp"
                   def libs = []
                   project.getReference( "core-cp" ).list().each { pe ->
                        if ( pe.endsWith( ".jar" ) )
                             libs.add( pe )
                   def noisy = "true".equalsIgnoreCase( project.getProperty( "noisy" ) )
                   // Copy:
                   libs.each { lib ->
                        def jfile = new JarFile( new File( lib ) )
                        def e = jfile.entries()
                        while ( e.hasMoreElements() ) {
                             def entry = e.nextElement()
                             def name = entry.getName()
                             if ( noisy )
                                  println "Copying \"${name}\" ..."
                             def is = new BufferedInputStream( jfile.getInputStream( entry ) )
                             try {
                                  copyBinary( entry.isDirectory(), "${destDir}/${name}", is )
                             finally {
                                  is.close()
              </groovy>
         </target>

  • SSIS 2012 Project Deployment with included EXE application not deployed in Catalog

    Hi,
    I have converted a SSIS solution consisting of 20 packages, two exe applications, and a web service to the project deployment model. My question is: where are the exe applications deployed to? I don't see them in the catalog on the server.  If I exclude
    these from the solution and disable the steps in the packages using them, everything works fine.  In BIDS, I can include the exe applications  and run the solution locally and it works fine. I have parameters for the path to the EXEs, but when configuring
    the path in the catalog, I am unsure what to set it to. Do I need to manually move these EXE applications to the database server separately from the deployment?
    THanks much,
    Pat 

    You can even put exes as files in file system in a shared folder and access them from packages in catalog. Just pass the paths (UNC) using parameters in package
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Including javahelp in a jar executable

    Hi, ive just created an application and would like to include a javahelp with it, ive got it running off my local machine with the java helpset working too , but what im wondering is, is it possbile to include jhall.jar in the application jar so people who do not have javahelp installed can still view the helpsets ? and if so how do i point to it so that it imports it when the helpset is called upon.
    here is my manifest file
    Manifest-Version: 1.0
    Class-Path: ./jhall.jar
    Created-By: NetBeans IDE
    Specified-By: studentbudget/StudentBudget.jarContent
    Main-Class: studentbudget/StudentBudget

    Hi, ive just created an application and would like to
    include a javahelp with it, ive got it running off my
    local machine with the java helpset working too , but
    what im wondering is, is it possbile to include
    jhall.jar in the application jar so people who do not
    have javahelp installed can still view the helpsets ?
    and if so how do i point to it so that it imports it
    when the helpset is called upon.
    Try this; - where 'help' is a dir in your jar.
         try
                   URL hsURL = getClass().getResource( "help/myhelpset.hs" );
                   hs = new HelpSet(null, hsURL);
                   // found helpset, allow help
                   HelpBroker hb = hs.createHelpBroker();
                             menuItemHelp.addActionListener(new CSH.DisplayHelpFromSource(hb));
                   // add help functionality to main menu
                   menuHelp.add(menuHelpHelp);
                   menuHelp.addSeparator();
                   menuHelp.add(menuHelpAbout);
                   menuBar1.add(menuHelp);
                   // add help functionality to toolbar
                   toolBarImages.addSeparator();
                   toolBarImages.add(buttonHelp);
              catch (Exception ee)
                   JOptionPane.showMessageDialog( null, "Be aware that online help could not be loaded.");
                   //System.out.println("HelpSet " + hs.getTitle() + " not found");
                   // helpfile not found. disallow help

  • Including pictures in a jar file

    Hi all, I want to create a jar file where I include a couple of pictures...... I have succesfully included them into the archive but I have found that the coding I use cannot be sued within a .jar file and hence none of the pictures are loaded :( I'm using kit.getImage("imagename.gif") command to load the images..... this does howeevr not seem to work when using a .jar file....... anyone got anyideas of what code should go instead of the kit.getImage("imagename.gif") ?
    Thx
    Garaz

    I would reply to that but I'll just stick with what
    you gave me..... thx for replying anyway, at a first
    look it seems as if I didn't specify the search
    pattern anough to get a good score when seraching....
    well thx for replyingDon't take it personally, this question has just been answered many times lately. I didn't feel like doing it again.

Maybe you are looking for

  • Problem in using FilenameFilter with FileDialog

    perhaps, i dont know how to use FilenameFilter with FileDialog because the following approach doesn' work FileDialog fd=new FileDialog(myframe,"Select an image"); fd.setFilenameFilter(new filefilter());                                                

  • When I syncing my new iPod into my iMac I can't get the old apps to the new iPod

    Hi When I have synced my new iPod to iTunes on my iMac I want to get my old apps into the new iPod. I can't do that it's always an error.!

  • Need advice: About record store

    Hi, I am developing an application which will first display a list of options to users (multiple choice i.e. with check boxes). The list of options could be anything, such as movie titles, etc. The application will need to allow users to select their

  • Active dataguad

    hi, i am trying to make standby database in 11g(active dataguard) through rman. but archive log list shown like below primary database SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/app/oracl

  • Foreign Trade Import/Export Tab in Material Master of SAP R/3

    Hi What is the use of Foreign Trade Import/Export Tab in material master of SAP R/3