Executing java apps without individual JAR file entries in CP???

Hi all,
I'm used to having to specific EACH separate jar file in the CLASSPATH when executing a java application. See the batch file example below.
Is there a way to not have to spell out EACH JAR file separately in this fashion? Eg just refer to the JAR directory?
What do people usually do here when delivering a java application to someone else, given the application has your own class files in a JAR, plus other 3rd party class files? Do you always have to build up a long JAVA batch file like the one below to enable the application to be run?
-----------example-------
c:\Progra~1\jdk1.3.1\bin\java -classpath .;deploy\mail.jar;deploy\activation.jar;deploy\xerces.jar;deploy\commons-digester.jar;deploy\commons-collections.jar;deploy\commons-beanutils.jar sns
Cheers
Greg

A simple way is to have a class inside your program load all the JAR files needed.
That way, when the main class file starts, place a call to the class that will load
the classes for you. Like this one below...
import java.lang.*;
public class MyJarLoader {
public MyJarLoader() {
System.load(String); // replace 'String' with the file pathname of a JAR file.
// you will need to do this for each JAR file, just add another call to System.load() here

Similar Messages

  • How to start java app with many jar files

    Hi,
    I have an application that makes use of 50 jar files. When I try to start the application, I need a very long command line like
    java -classpath file1.jar;file2.jar;file3.jar; ... de.me.myapp.myclass
    This is not very handy. Is there a shorter way if all jars are in the same directory? I would like a command like this:
    java -cp /usr/local/my_jars de.me.myapp.myclass
    but this does not work.
    Any Idea if there is an easy solution?
    Andreas

    aaa801 wrote:
    i think there was a way to do it but it eather only worked with javac or java exe which is a lil problem but i did -cp .;./*.jar or something of that sortAs of Java 6, the classpath can contain wildcards.
    http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html

  • Launch Java app through a bat file

    Hi,
    Because I have to launch my Java App through a batch file, I don't know if I can create a new java class to execute this bat file to launch my Java App? Is that gonna work?
    Henry.

    Yes I created a batch file and tested. If I execute my batch file, the java app will be lauched as expected.
    Here is my java class that execute my batch file
    import java.io.*;
    public class LaunchTest {
    public static void main(String args[])
    String cmd[] = new String[3];
    try
    String osName = System.getProperty("os.name" );
    //System will detect current operating system
    if( osName.equals( "Windows NT" ) || osName.equals( "Windows 2000" ) )
    cmd[0] = "cmd.exe" ;
    cmd[1] = "/C";
    cmd[2] = "c:\\Run.bat"; //Run.bat will set classpath and launch my java app
    else if( osName.equals( "Windows 95" ) || osName.equals( "Windows 98" ) )
    cmd[0] = "command.exe" ;
    cmd[1] = "/C";
    cmd[2] = "c:\\Run.bat";//Run.bat will set classpath and launch my java app
    Runtime rt = Runtime.getRuntime();
    //running the commands
    Process proc = rt.exec(cmd);
    // any error message?
    StreamGobbler errorGobbler = new
    StreamGobbler(proc.getErrorStream(), "ERROR");
    // kick them off
    errorGobbler.start();
                   // any error???
    int exitVal = proc.waitFor();
    catch (Throwable t)
    t.printStackTrace();
    System.out.println("error...");
    And here is my batch file
    @echo off
    set path=e:\jbuilder4\jdk1.3\bin
    set classpath=E:\JBuilder4\jdom-b7\jdom-b7\build\jdom.jar;E:\JBuilder4\jdom-b7\jdom-b7\lib\xerces.jar;.
    d:
    cd AutoTest\classes
    java FirmwareTestPack.FirmwareMainClass
    exit
    When I run the java class above, Dos prompt popped up for a second then disappeared. It did not launch my Firmware pplication.
    Thank you.

  • Can't run JavaFX app as a jar file from command line

    I'm trying to build a JavaFX app from scratch (that is, by including the jar file from the JavaFX SDK rather than by using the special JavaFX project type from NetBeans). It runs fine in NetBeans. However, when I try to launch it as a jar file from the command line (using "java -jar dist\TestApp") I get the following. Has anybody seen this before, and if so how can I fix it?:
    *** Fallback to Prism SW pipeline
    Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLink
    Error: Can't load library: C:\dev\TestApp\dist\bin\mat.dll
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
    289)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:68)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
    pl.java:145)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
    27)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:97)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\dev\RedactionT
    oolPrototype\RedactionToolPrototype.Core\dist\bin\mat.dll
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoad
    er.java:155)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoad
    er.java:85)
    at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:
    30)
    at com.sun.glass.ui.Application$1.run(Application.java:28)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:26)
    at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
    at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
    Factory.java:20)
    at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
    Factory.java:17)
    at com.sun.glass.ui.Application.Run(Application.java:51)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
    279)
    ... 5 more

    Unsatisfied link means that Java is trying to access a native library, but it cannot be found. As to why this error is being thrown, here is my guess:
    If you open up one of the sample jars with a zip viewer, you will see that the Manifest file has the following entries:
    >
    Manifest-Version: 1.0
    JavaFX-Version: 2.0
    implementation-vendor: Oracle
    implementation-title: BrickBreaker
    implementation-version: 1.0
    JavaFX-Application-Class: brickbreaker.Main
    Created-By: JavaFX Packager
    Main-Class: com/javafx/main/Main
    >
    In other words, a JavaFX project works a bit differently than a normal Java project. com/javafx/main/Main is used as the Main class and your "Main" class is called later.
    If you are trying to build this from a normal Java project, then com/javafx/main/Main will not be created and it will call your Main class right away. Thus, whatever setup is needed to run JavaFX will not occur.

  • How to run a java program using additional jar files

    Hi everyone in the forum,
    i ve created an app using the hFreeChart in eclipse, so i added them as external jar files and tested the program.
    now my problem is that the program should run using a terminal in win and i do not know how can i do to make the command line or the system to find them, i added to the path but i read somtehing about classpath, but i have no idea. if anyone can help?
    thanks in advanced

    Actually, the best way to prepare a program for regular running is to make it an executable jar file, which means adding a manifest file which contains (at least) a Main-class: and a Class-Path: line. Referenced class libraries typically sit in a lib directory next to the java file. Then you can run it using java -jar myprog.jar.
    Failing that create a batch file or link that supplied java with command line parameters including a -classpath=
    Using the class path environment results in too much contention between competing values of it.

  • Target to execute multiple junit tests from jar file

    I have written a custom selenium framework using JUnit and Selenium, problem I am having right now is our team wants to run the tests inside HP Quality Center (I have no idea or any experience with Quality Center) but if I provide a jar file the them they can execute it inside the Quality Center (Reason to run it in Quality Center is for reporting purpose).
    Problem is that I have created my framework in away that You can create multiple JUnit base test files for different tests also keep in mind that these classes dont need main method (This is where the problem when it comes to jaring up ). I have introduced following ant target to run all the test cases.
         <target name="test.selenium" depends="jar" description="target to execute all the selenium tests.">
              <junit printsummary="yes">
                   <classpath>
                        <path refid="classpath"/>
                        <path refid="application"/>
                   </classpath>
                   <batchtest fork="yes">
                        <fileset dir="${src.dir}" includes="**/Test*Selenium.java"/>
                   </batchtest>
              </junit>
         </target>above ant target runs without any problem, but when you jar it up you need a manifest and main class, is there away I cant introduce some attribute that can execute all my tests without adding main method to each of them.
    Here is my ant target for jar
         <target name="jar" depends="compile"
                   description="Generates final jar">
              <copy todir="${build.jar}">
                   <fileset dir="lib" excludes="**/*.java"/>
              </copy>
              <jar jarfile="${build.jar}/yukonSelenium.jar"
                        basedir="${build.classes}">
                   <manifest>
                        <attribute name="Main-Class" value="com.somepackage.selenium.test.TestAuthenticationSelenium"/>
                        <attribute name="Class-Path"
                             value=". /c:/build/jar/log4j-1.2.15.jar /c:/build/jar/junit-4.6.jar /c:/build/jar/selenium-java-client-driver.jar /c:/build/jar/dom4j-1.6.1.jar"/>
                   </manifest>
              </jar>
         </target>And this is how the Test Class looks like, I have added main method in this but once i do this after jaring java -jar myJarfile.jar will only execute just the class i have main method init.
    public class TestAuthenticationSelenium extends SomePrivateFrameWorkClass {
         private void init() {
              start();
         @Test
         public void testProductNav() {
                //somecode
         @Test
         public void multipleLogin() throws FileNotFoundException, InterruptedException {
                             //Some Code
         public static void main(String[] args) {
              org.junit.runner.JUnitCore.main("com.somepackage.selenium.test.TestAuthenticationSelenium");
    }Please let me know if i should put the entire ant build file.
    Thanks for any help.
    anuradha.uduwage
    Edited by: Tilter on Aug 24, 2009 10:05 PM
    Edited by: Tilter on Aug 24, 2009 10:06 PM

    What i mean is if i have 3 class files in my jar file, and each one of those classes has a main method, how will i be able to execute a class of my choice from that jar file. In manifest files, you specify the main class, but how would i specify multiple classes with main methods, or achieve my objective here.

  • Enumerating Jar file entries

    At the risk of invoking the wrath and contempt of forum watchers the world over, I wish to reopen this can of worms.
    I'm writing a Java program to play cribbage, and I have finally succeeded in getting it to run as a jar. My package structure for the jar is as follows.
    cribbage (contains all the cribbage-specific processing)
    .....images (contains board.png)
    cards (contains general card-related processing)
    .....images (contains cards*.png, backs*.png)
    common
    .....util (contains combinatorial math routines)
    If I run through the JarFile enumerating entries, it stops after cribbage/images. My first question is therefore "How can I get beyond cribbage/images and into cards/images, which is where I REALLY want to be?"
    The cards/images part of it contains, at the moment 5 cards*.png and 3 backs*.png, defining different card face styles and card back collections, but I may wish to change those nmbers in the future, without hard coding names in the code. This is why I wish to enumerate these entries, to give a player the chance of choosing styles and card backs from a flexible set of alternatives.
    Since I may write a program in future to play starchplonkers or gurglemuffins (both card games) I'd really like the card-related stuff to be separated from the cribbage stuff - same with the common stuff - but, as soon as I put cribbage into a jar I can't access any other locally written packages, unless someone can suggest a way of organizing packages more efficiently.
    I have been programming for close to 40 years, but only recently decided to exploit certain aspects of Java, like packages and jars.

    OK. First, here's the structure of the jar file:
    F:\Java\Packages>jar tf Cribbage.jar
    META-INF/
    META-INF/MANIFEST.MF
    cribbage/CardPanel.class
    cribbage/Cribbage$1.class
    cribbage/Cribbage$CribbageCardComparator.class
    cribbage/Cribbage$LogFileFilter.class
    cribbage/Cribbage$MsgLineRenderer.class
    cribbage/Cribbage.class
    cribbage/CribbageBoard.class
    cribbage/CribbageDealer$RecordedGame.class
    cribbage/CribbageDealer$RecordedHand.class
    cribbage/CribbageDealer.class
    cribbage/images/
    cribbage/images/board.png
    cards/Card.class
    cards/CardDeck.class
    cards/CardFactory.class
    cards/images/
    cards/images/backs1.png
    cards/images/backs2.png
    cards/images/backs3.png
    cards/images/cards1.png
    cards/images/cards2.PNG
    cards/images/cards3.PNG
    cards/images/cards4.png
    cards/images/cards5.png
    common/util/Combinations.class
    common/util/Derangements.class
    common/util/Hex.class
    common/util/Ordinal.class
    common/util/Permutations.class
    common/util/StringKit.class
    common/util/TestCombinations.class
    ..and the code:
    try {
    JarFile jarfile = new JarFile( "cribbage/Cribbage.jar" );
    Enumeration<JarEntry> entries = jarfile.entries();
    while ( entries.hasMoreElements() ) {
    JarEntry entry = entries.nextElement();
    System.out.println( "Entry: " + entry + ", " + entry.getName() );
    } // while
    } catch (IOException e) {
    e.printStackTrace(System.err);

  • Can't execute a main class with jar file loaded on command line

    Hello Guys,
    I try to use the following command to execute a main metod from msword class.
    java -cp f60all.jar:jacob.jar msword
    and i receive:
    Exception in thread "main" java.lang.NoClassDefFoundError: msword
    If i extract the 2 jar files then i can execute the main metod:
    java msword
    Can anyone explainme whet is happening ?
    Thanks,
    /Marian

    Hi!
    You need to include the directory where your class is in your classpath... you can use for this the "."
    So, you should write something like
    java -cp .;f60all.jar;jacob.jar msword
    and this supposing that "f60all.jar", "jacob.jar" and "msword.class" are all in the same directory from which you are trying to run the program... in other case write the full paths for the files...
    Bye!

  • Simple but wierd java.lang.NoClassDefFoundError with jar file

    I'm using ant to jar my .class files. My final objective is to create an executable jar. When I run my jar file - "java -jar PM.jar" - I get:
    Exception in thread "main" java.lang.NoClassDefFoundError: pm/PMApp
    This at least tells me that java found my MANIFEST.MF class and that is the correct class it should be looking for, but it doesn't seem to find the class. But when I do - "jar -tf PM.jar" - I get:
    C:\mike\pm\execs>jar -tf PM.jar
    META-INF/
    META-INF/MANIFEST.MF
    pm/
    pm/EasterEgg.class
    pm/JMSMessageListener.class
    pm/PMApp.class
    pm/ReleasePlanTest.class
    pm/SystemArchitectureFrame$1.class
    pm/SystemArchitectureFrame$2.class
    pm/SystemArchitectureFrame$3.class
    pm/SystemArchitectureFrame$4.class
    pm/SystemArchitectureFrame$5.class
    pm/SystemArchitectureFrame$6.class
    pm/SystemArchitectureFrame$7.class
    pm/SystemArchitectureFrame$8.class
    pm/SystemArchitectureFrame.class
    pm/SystemArchitecturePanel.class
    Which shows me that the class is there. I suspected that it might have something to do with CLASSPATH at first because of the java.lang.NoClassDefFoundError, but now I am skeptical that that could be the problem. I even build a new jar file out of different classes to make sure my method was OK and that worked fine. Any ideas? Thanks for your help in advance.

    Here is my Manifest:
    Main-Class: pm.PMApp<carriage return>
    Class-Path: C:/j2sdkee1.3.1/lib/j2ee.jar<carriage return>
    I noticed that if I leave the Class-Path variable unset it has no problem finding the class pm/PMApp, but I then get a class loader error concerning J2EE stuff. Am I missing something in my Class-Path? I tried to even specify the jar file I'm running here, but that didn't work either? I have also tried '.' and './', space delimited in my Class-Path, like this:
    Class-Path: . ./ C:/j2sdkee1.3.1/lib/j2ee.jar<carriage return>
    Thanks for the replies, do you have any more suggestions?

  • How to bundle java help class into jar file ?

    Hi, all,
    I have some package in my project, with which I have a java help jar file as classpath, when I run my project, I need the jh.jar file in directory /jar/jh.jar.
    Now, I bundled all my class packages into a jar file, my.jar, together with the /jar directory. When i run my jar file with command:
    java -jar my.jar
    It tells me couldn't find javahelp class.
    What shall I do? How can I create my jar file with the jh.jar?
    Thanks in advance.

    I think you'd be better off just adding the jh.jar as
    a classpath argument and running it like that:
    java -classpath /myjavalibdir/jh.jar -jar myjar.jar
    ...otherwise you're stepping into redistribution of
    binary issues licensing-wise. That won't work either; when you run java with the -jar option, it ignores both the -classpath option and the CLASSPATH environment variable. However, it will see jh.jar automatically if you put it in the <path-to-java>/jre/lib/ext directory. But for distribution purposes, it might be simpler just to combime the contents of jh.jar into myjar.jar (if you use Ant, its <jar> task makes that very easy). Or, you can just run it this way:java -classpath myjar.jar;jar/jh.jar MyMainClassBTW, I don't think redistribution is a problem; otherwise how anyone even use JavaHelp?

  • Java Applet fails loading JAR files

    I'm using the OC4J setup with my Oracle forms (10g) install, this was working but no longer.
    I get the message below when running the test.fmx from the Oracle Forms Services test page for each of the JAR files attempting to load.
    I comment out the ARCHIVE statement but it still fails with
    'java.lang.ClassNotFoundException:oracle.forms.engine.Main' on the applet window.
    =====================
    java.io.IOException: Connection failure with 504
         at sun.plugin.protocol.jdk12.http.HttpURLConnection.getInputStream(Unknown Source)
         at oracle.jre.protocol.jar.HttpUtils.followRedirects(Unknown Source)
         at oracle.jre.protocol.jar.JarCache$CachedJarLoader.isUpToDate(Unknown Source)
         at oracle.jre.protocol.jar.JarCache$CachedJarLoader.loadFromCache(Unknown Source)
         at oracle.jre.protocol.jar.JarCache$CachedJarLoader.load(Unknown Source)
         at oracle.jre.protocol.jar.JarCache.get(Unknown Source)
         at oracle.jre.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
         at oracle.jre.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
         at sun.misc.URLClassPath$JarLoader.getJarFile(Unknown Source)
         at sun.misc.URLClassPath$JarLoader.<init>(Unknown Source)
         at sun.misc.URLClassPath$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.misc.URLClassPath.getLoader(Unknown Source)
         at sun.misc.URLClassPath.getLoader(Unknown Source)
         at sun.misc.URLClassPath.getResource(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    WARNING: error reading http://nzmdgrenfell01.asiapacific.hpqcorp.net:8889/forms/java/frmwebutil.jar from JAR cache.
    Downloading http://nzmdgrenfell01.asiapacific.hpqcorp.net:8889/forms/java/frmwebutil.jar to JAR cache
    java.io.IOException: Connection failure with 504
    Any suggestions?
    Regards......Derek

    I found this Metalink that solved my problem.
    Note:171159.1

  • Java.nio.channels.FileChannel jar file

    Hi
    I have used java.nio.channels.FileChannel package in my program.
    where can I get the jar file which has the above package?
    Thanx

    i give here sample code.. use this it will work fine..
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    public class copyImage
    public static void main(String [] args) throws IOException
    try {
    // Create channel on the source
    FileChannel srcChannel = new FileInputStream("dragonfly.jpg").getChannel();
    FileChannel dstChannel =new FileOutputStream("1.jpg").getChannel();
    // Copy file contents from source to destination
    dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
    // Close the channels
    srcChannel.close();
    dstChannel.close();
    } catch (IOException e) {
    }

  • How to compile .java to .class in .jar file

    Hey. I have code to make a .jar file, read .java files, and save them as .class files in the .jar file. When I open the .jar file, it says that the magic numbers on the classes are wrong. So I figured that Java must compile the .java files to .class files in bytecode.
    Question: What's the code to compile a string from a .java file to a .class file?
    Here's my code:
    try {
                // Name of jar file to write
                String archiveFile = Name + ".jar";
                Manifest jman = new Manifest();
                try {
                    // Create a manifest from a file
                    //InputStream fis = new FileInputStream("manifestfile");
                    //Manifest manifest = new Manifest(fis);
                    // Construct a string version of a manifest
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("Manifest-Version: 1.0\n");
                    sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
                    sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
                    sbuf.append("Main-Class: Main\n");
                    sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
                    sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
                    // Convert the string to a input stream
                    InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
                    // Create the manifest
                    jman = new Manifest(is);
                } catch (IOException e) {
                FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
                JarOutputStream out = new JarOutputStream(stream, jman);
                out.putNextEntry(new JarEntry("Main.class"));
                StringBuffer sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("Main.txt")));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.putNextEntry(new JarEntry("MainScreen.class"));
                sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("MainScreen.txt"));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.putNextEntry(new JarEntry("GCanvas.class"));
                sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("GCanvas.txt"));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.close();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.toString(), "BUG!", JOptionPane.INFORMATION_MESSAGE);
                ex.printStackTrace();
            }Thanks,
    -Gandolf

    So I'm guessing that none of you guys have the knowledge on how to compile a java application within a java application. I was thinking that it had something to do with javac... but I'm unsure.
    If no one can answer the question, could someone point me to an expert who would know?
    -Gandolf

  • Jar File Entry Names (separator)

    How goes it everyone?
    I wrote some code to find a class on the classpath, which goes through the directories and jars on the classpath to find the class in question. It works fine on Linux but when I try to run it from a .jar on Windows it fails.
    I tracked this down to the fact the the File.separator for files on Linux and Windows is different (which the code takes into account), but the File.separator for entries in a jar file is "/" on both. Anyone know if this is always the case, like on IRIX, Solaris and Macs? Is there a constant like JAR_FILE_SEPARATOR or something?
    I looked around for some documentation on the subject but couldn't find an authority on the subject. 2 DD's to the first with a link.
    Josh

    you may use the special .jar tool to do it.
    www.pivotonic.com
    JavaJar1.1
    you can add files to .jar file like winzip.
    and you can edit and check correct the manifest file in JavaJar editor.
    why not try it?

  • Jar file entry - file on users machine

    Hi,
    I am having trouble with the formatting of a file when I attempt to copy it from a jar file to a user directory. It copies the file to the correct dir, but somehow removes all newlines. Does anyone know what I am doing wrong?
    The code is posted below. The ResourceManager just uses the getClassLoader().getResourceAsStream() method to return an InputStream object to the jarred-up file.
      public static void loadLocalDatabase()
        try
          File rootdirectory = new File(getRootDir());
          if(!rootdirectory.exists())
            rootdirectory.mkdir();
          // load the database file from the local database jar
          // into a file on the users local machine
          File output = new File(rootdirectory, databaseFilename);
          if(output.exists())
            return; // if the database file exists, we dont want to overwrite it
          FileInputStream databaseOriginal = new FileInputStream(ResourceManager.getInputStream(databaseFilename));
          byte[] file = new byte[databaseOriginal.available()];
          databaseOriginal.read(file);  // put the contents into the array
          FileOutputStream fos = new FileOutputStream(output); // write the contents out.
          fos.write(file);
          fos.flush();
          fos.close();     
        catch(Exception e)
          System.out.println(e.getMessage());
          e.printStackTrace();
      }Thanks,
    Dave Smith

    Ah. Just a little update: that FileInputStream should just be an InputStream

Maybe you are looking for

  • Display Resolution with Beige G3

    Hello, I am running a G3 Beige with an OWC G4 500 MHz OWC upgrade processor. The machine is running Mac OS 10.4.8 well. I love to have more choice in the display resolution. A few days ago, I accidentally touched a couple of things, and was able to c

  • The '$' character no more allowed in java identifier since JDK 1.4.2 ?

    Since JDK 1.4.2, I'm no more able to compile java sources. :-(( Their compilation worked fine on 1.3 and 1.4.1. Note that these java sources are generated automatcally via a tool. <b>The $ (dollar) character seems to be no more allowed in java identi

  • Replacing PS4 HDD with an old 1TB HDD

    Hello Everyone, I have recently bought a PS4 which will be delivered within 1-2 days. I really wanted a larger Hard drive as I think 500 GB won't be enough for me so I decided that I will upgrade my HDD to 1 TB before using my PS4. I have a 1 year ol

  • Network name

    How do I change the name of my network? The cable guy set it up as my last name. I'd like something a little more ambiguous.

  • How do i fix pogo games to work using firefox.need to block java platform Se7u

    i just bought a new computer with window 8 and i cant get pogo games to work. Had internet explorer and took it to someone to get it to work.. they put mozilla on it and it worked for awhile then something came up and i it allow instead of block when