JAR executable not executing

This isn't a question, it is just a brief description of a problem I had and the solution since this bugged me for a bit.
I was running my application on netBeans and it was working wonderfully etc...netBeans also will create an executable JAR for you when you build your app. However this JAR was not executing I was getting a null pointer exception where I was loading one of my images.
The problem was a basic one...case sensitivity. My filename was .png instead of .PNG.
The interesting thing is netBeans didn't care about this as it runs the app from the build directory and not the JAR it creates. So all along I never thought my file names were wrong. But apparently JAR files care about the case I guess because of running on different platforms like linux who care about case.
So make sure your case is right even if your IDE is compiling your code.
Just a heads up.

see this link
http://neptune.netcomp.monash.edu.au/JavaHelp/howto/jar.htm
for ex - usuppose ur project located in D:/ dir like this pakage structure
test
----src
--- one.java
--- two.java
if u want to create jar file for this package u have to give command prompt like this
d:\test\src>jar cf filename.jar *.java - this jar file contains only java files

Similar Messages

  • JAR Executable works in netbeans but not under Dos?

    Hi all,
    I have created a jar executable and it works fine in netbeans(it was not created in netbeans) but I can't get it to run on the command line. If I type java ClassName.MainClass it will run but not using the command java JarFile.jar or java -jar JarFile.jar
    Any help would be most appreciated.

    When creating the manifest file did you add a carriage return at the end of the manifest? e.g.
    Main-Class:Hello.class
    (carriage return here on new line)
    I think it runs into problems if you dont add a carriage return ( a new blank line after manifest).
    Hope this helps
    Riz

  • How to get a file in the same dir with the jar-executable

    Hi,
    I need to read/write a file that exists in the same directory with the jar-executable. How can i do that? I think that when i specify no path for the file, the file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and the file are.
    Thanx in advance

    Hi,
    I need to read/write a file that exists in the same
    directory with the jar-executable. How can i do that?
    I think that when i specify no path for the file, the
    file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and
    the file are.
    Thanx in advance
    When you specify no path for the file, the file has to be in the directory where the virtual machine was started. ( the directory the java command was invoked in .)
    If you can't control the directory in which the vm is started, but you know the name of the .jar file you can do the following. This trick takes advantage of the fact that if you are using classes in a jar file, the name of the jar file must be in your classpath.
    public static String getPathOfJar( String nameOfJar )
    throws Exception
    StringTokenizer st = new StringTokenizer(
    System.getProperty( "java.class.path" ) ,
              System.getProperty( "path.separator" ) );
    String jarfile = "";
    while ( st.hasMoreTokens() )     
    String token = st.nextToken();
    if ( token.indexOf( nameOfJar ) > -1 )
    jarfile = token;
    break;
    if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
    String path = jarfile.substring( 0 , jarfile.indexOf( nameOfJar ) );
    return path;
    //To open a file in the same directory as the sun archive tools.jar
    File f = new File( getPathofJar( "tools.jar" ) + "someFile.txt" );

  • Double clicking jar executables

    Hi everyone
    I know that this topic has been discussed before - but I have scanned all discussions, and the problem hasn't been solved yet. There have been some good suggestions, but no definitive solution provided.
    I have a jar executable supplied to me by a commercial software company. The application is packaged in a jar file. I have checked that the manifest has the correct Main-Class association in it. I can install the jar on some Win 2000 copmuters and it executes fine by just double clicking on the jar file. On my laptop which also has Win 2000 OS it simply refuses to execute. The very frustrating JVM Launcher error message "Could not find main class. Program will exit." is displayed.
    The only way that I have found to get around it is to put a batch file in the same directory as the jar file containing "start /MAX javaw -jar "C:\Program Files\EqWave\eqwave181\eqwave.jar"" and execute this batch file from a shortcut placed on the desktop. Not a very good work-round - but at least it works.
    What I can't figure out is why the jar will work when double clicked on some computers, but not on my laptop. Obviously it has something to do with my laptop setup.I have reinstalled the latest jre-1_5_0-windows-i586.exe, but it still won't work.
    Please, please, pretty please - what am I doing wrong?????
    Cheers
    Mike T

    On your laptop the file association could be wrong : check if the file association with .jar is "javaw -jar" and not only "javaw".
    It looks like the "-jar" option is missing in the command field of your file association...
    On my Windows 2000 computer, the file association for .jar is :
    "C:\Program Files\Java\j2re1.4.1\bin\javaw.exe" -jar "%1" %*Modify your file association and I bet it will be better.

  • How to run a Jar executable with non standard JVM memory settings

    Hi,
    I have a jar-executable that needs more memory than the JVM uses by default.
    The application works with:
    java -Xms128M -Xmx256M myapp
    How can the jar know that it need to start like this?
    I found a solution here http://forum.java.sun.com/thread.jsp?forum=32&thread=188484 , but i don't want to do this with a shortcut.
    Is there anyway to do this?
    Thanx in advance.

    Well i'll do that:
    public class launch
      public static String getJarPath()
        String path="";
        try
          StringTokenizer st = new StringTokenizer(System.getProperty( "java.class.path" ) ,System.getProperty( "path.separator" ) );
          String jarfile = "";
          while ( st.hasMoreTokens() )
            String token = st.nextToken();
            if ( token.indexOf("launch.jar") > -1 )
               jarfile = token;
               break;
          if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
          path = jarfile.substring( 0 , jarfile.indexOf("launch.jar"));
       catch (Exception e)
        new AlertWin(e.toString());
       finally
        return path;
      public static void main(String[] args)
        try
          String path=launch.getJarPath();
          Runtime.getRuntime().exec("javaw -Xms128M -Xmx256M -jar " + path + "toBeExecuted.jar");
        catch(IOException e)
          new AlertWin(e.toString());
    }The launch.jar has to be in the same dir with the toBeExecuted.jar. (ofcourse that could change and the code is much simpler).

  • How to install a jar executable as a Win XP pro NT Service

    hi folks.
    Got a .jar file (compiled it in JBuilder, archived it as "Application" it executes by double clicking it. It works by scheduling it through schdule tasks...
    However I would like to run the JAR executable as a Windows Service (Win XP Pro). Is this possible in java?
    I have done similar thing in .NET C#/vb.net but service creation/processing is written within the code. All you do is go to dos prompt and type net start ... etc.
    How can I do the same in java?
    Please assist.

    Got a .jar file (compiled it in JBuilder, archived it
    as "Application" it executes by double clicking it.
    It works by scheduling it through schdule tasks...
    However I would like to run the JAR executable as a
    Windows Service (Win XP Pro). Is this possible in
    java?It might be possible, but knowing anything about OS specific stuff is not what Java is intended for. There is a Runtime.exec() method provided for any OS - specific stuff.

  • Sending Command Line Arguments to Jar Executable

    Hi All
    I wish to send Command Line Arguments to Jar Executable.
    i.e. before I Jar'd my program, I would do the following
    public class CmdLnArgmntExp {
    public static void main(String[] args) {
    System.out.println("d");
    for (int i = 0; i < args.length; i++)
    System.out.println(args);
    Running the program in Console.
    Java CmdLnArgmntExp arg1 arg2 arg3 arg4Output:
    arg1
    arg2
    arg3
    arg4
    How would I do this to a Jar executable, hope that made sense
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    java -jar executable-jar-file-containing-class-CmdLnArgmntExp.jar arg1 arg2 arg3 arg4

  • Jar executable issue after jvm update

    I created a small demo application and bundled my classes and media files in a jar executable file. Everything was fine until I updated J2SE from 1.5.0 to 1.6.0_01.
    The application now starts, gets its input normally but soon after hangs, and the Swing GUI doesn't show up anymore.
    The jar file contains 4 packages (one of them contains the main class) and this simple manifest file:
    Main-Class: myapp.myAppLauncher
    Classpath: .\myapp.jar
    I created the jar as follows:
    jar cvfm gdv.jar Manifest.txt myapp mypackage2 mypackage3 mypackage4
    I recompiled the source before creating the jar archive, and if I launch the application from the console I see no difference from before. The problem is only for the jar version.

    Manually download and install the Java 4 update http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105 update4.html, and Safari 4.0.1 http://www.apple.com/safari/download/ Run Software update, install anything that pop up, repair permissions, and restart. That should fix your problem.

  • How do I put my jar executables into a cab file to create a setup/install?

    I want to create a setup program for installing my jar executable. I've seen ones that create cab files with a setup.exe program and would like to do the same. Any suggestions?

    Well, JARs generally don't have support files. That's the whole idea. A JAR is designed to be a stand alone application. You don't really need to install it, for that matter. I just thought you might be wanted shortcuts or something.
    Actually, there is some way to install Java programs through Java Web Start, if you want to check that out. I don't know anything about it, though.

  • Export jdeveloper as jar executable file

    hello, I have a simple application developed using jdeveloper which access an oracle database and retrieve data. I would like to export this application as jar executable file. how can I do this using jdeveloper.
    Best regards

    Add a manifest file that identifies the main class. If you have questions on how to do that using your IDE, I suggest you hit 'F1' or visit a forum that deals with that IDE.

  • Error by compiling yacy: Target "build-jar" does not exist

    Hello
    I am trying to compile yacy by using this PKGBUILD (based in this one: http://aur.archlinux.org/packages.php?ID=14464):
    pkgname=yacy-svn
    pkgver=7387
    pkgrel=1
    pkgdesc="Peer to peer searchengine"
    arch=(i686 x86_64)
    url="http://yacy.net/"
    license="GPL"
    depends=('java-runtime' 'sudo')
    #depends=('jre' 'sudo')
    #makedepends=('jdk' 'apache-ant' 'subversion')
    makedepends=('apache-ant' 'java-environment')
    conflicts=(yacy)
    replaces=()
    provoids=(yacy)
    install=yacy.install
    source=()
    md5sum=()
    _svntrunk=svn://svn.berlios.de/yacy/trunk/
    _svnmod=yacy
    build() {
    cd $startdir/src/
    msg "Checking out svn-tree..."
    svn co -r $pkgver $_svntrunk $_svnmod || return 1
    cd $startdir/src/yacy/
    msg "Create working directory"
    cp -r $startdir/src/yacy $startdir/src/yacy-work
    rm -rf $(find "$startdir/src/yacy-work" -type d -name ".svn" -print)
    # svn-file, that buildscript can determine revision
    mkdir -p $startdir/src/yacy-work/.svn/
    cp $startdir/src/yacy/.svn/entries $startdir/src/yacy-work/.svn/entries
    cd $startdir/src/yacy-work/
    msg "compile and copy files..."
    ant build-jar installonlinux -DDESTDIR=$startdir/pkg || return 1
    mkdir -p $startdir/pkg/usr/share/java/yacy/
    cp lib/*.jar $startdir/pkg/usr/share/java/yacy/
    cp libx/*.jar $startdir/pkg/usr/share/java/yacy/
    mkdir -p $startdir/pkg/etc/rc.d
    m4 -DArchLinux $startdir/src/yacy/addon/yacyInit.m4 >yacy.init || return 1
    install -Dm755 yacy.init $startdir/pkg/etc/rc.d/yacy
    msg "Delete working directory"
    rm -rf $startdir/src/yacy-work
    But in the process I get this error:
    Buildfile: ~/yacy/src/yacy-work/build.xml
    BUILD FAILED
    Target "build-jar" does not exist in the project "YaCy".
    I have searched information related using google but I don't find one solution.
    I think it is a java related problem. I have installed Oracle's Java Runtime Environment jre-6u23-1
    I use Archlinux x86 2.6.36-2.
    Can anyone help me please?
    Thanks in advance

    OK
    Still I can't install yacy, but I was reading the file readme.txt included in the program's tarball.
    There, says to start yacy run:
    ./startYACY.sh
    I get this terminal output:
    ****************** YaCy Web Crawler/Indexer & Search Engine *******************
    **** (C) by Michael Peter Christen, usage granted under the GPL Version 2 ****
    **** USE AT YOUR OWN RISK! Project home and releases: http://yacy.net/ ****
    ** LOG of YaCy: DATA/LOG/yacy00.log (and yacy<xx>.log) **
    ** STOP YaCy: execute stopYACY.sh and wait some seconds **
    ** GET HELP for YaCy: see http://wiki.yacy.net and http://forum.yacy.de **
    >> YaCy started as daemon process. Administration at http://localhost:8080 <<
    When I have tried to access to localhost, I get the following message:
    Error connecting to localhost. Connection refused.
    But from terminal I can ping to localhost
    Can anybody help me with any of this troubles please?
    Last edited by zuargo (2011-01-08 15:55:48)

  • Jar command not available

    Hi,
    I have a new Java programmer and I have installed the following software onto my PC:
    1) Java SE Development Kit 6u1 and NetBeans IDE 5.5.1 Bundle
    2) Sun Java Toolkit 1.0 for CDC
    3) JBuilder 2005 Foundation
    Now, I am trying to make a "jar" file with the following command:
    " jar -cf test.jar *.class "
    And my system reports the following:
    " 'jar' is not recognized as an internal or external command, operable program or batch file. "
    I have Java SDK, and IDE installed in my PC, and yet "jar" is not available. How could this be possible? What happen? Kindly advice, please!
    Regards,
    wee

    jar is an executable in your JDK installation directory that needs to be pointed to or else it will not recognize it.
    You can specify the bin directory of your JDK in your PATH environment variable or simple type an absolute path to jar.exe in the commandline.
    "C:\Program Files\[jdk directory]\bin\jar" -cf test.jar *.class

  • SDK 4.0.0.5: CM.jar Is Not Copied BUG-cm_jars_structure.xml.example Missing

    Could someone please help me out. I am trying to fix this bug with:
    SDK 4.0.0.5: CM.jar Is Not Copied into the Package To Be Deployed [ID 1315169.1]
    And according to Oracle support I need to:
    Solution
    In SDK version 4.0.0, the cm.jar gets copied only in etc/lib folder. In the target environment it gets distributed by executing initialSetup.sh, which is part of the CM installation.
    The structures/cm_jar_structure.xml should be created for the cm.jar distribution. You can see an example of the structure under the pkg scripts folder: etc/cm_jars_structure.xml.example (it just needs to be copied to structures/cm_jar_structure.xml). The cm.jar will then be copied to the correct locations in the application.
    But I am missing the file cm_jars_structure.xml.example.
    Does some have that file please?

    Hi,
    Here the comment from the FW_jars_strucure.xml.
    <!-- for list_of_AND_conditions all conditions must be true for jar to be distributed       -->
    <!-- for list_of_OR_conditions any of the conditions must be true for jar to be distributed -->
    <!--
       example:
       <jar_name>
          <source_dir_jar>source directory where the jar file is located (mandatory)</source_dir_jar>
          <dest_folders>
             <dest_folder_1>destination 1</dest_folder_1>
             <dest_folder_2>destination 2</dest_folder_2>
             <dest_folder_3>destination 3</dest_folder_3>
          </dest_folders>
          <list_of_AND_conditions>
                <condition_1>SPLWAS=WLS</condition_1>
                <condition_2>DBNAME=TESTING</condition_2>
          </list_of_AND_conditions>
          <list_of_OR_conditions>
                <condition_1>DBUSER=cisuser</condition_1>
                <condition_2>DBUSER=CISUSER</condition_2>
          </list_of_OR_conditions>
          if child jvm path exists, then the jar file from the location specified
          here will be added to class_path (child_jvm_option)
          <child_jvm_path>PATH where jar file is located</child_jvm_path>
          <target_folder>(subfolder under java/target used as basedir for jar creation)</target_folder>
          <copy_classes>true (set to true if during install single fixes the class should just copied to $SPLEBASE/java/target)</copy_classes>
          <update_source_jar>
             <update_source_jar_1>(list here the folder that should be updated in base-shared-${jversion}-src.jar. eg.: source/base)</update_source_jar_1>
             <update_source_jar_2></update_source_jar_2>
          </update_source_jar>
       </jar_name>
       Uncomment the following block for testing
       ensure you have a test.jar under $SPLEBASE/etc/lib
       The jar file will be copied if SPLWAS=WLS and DBNAME=TESTDB and
       DBUSER is either cisuser or CISUSER.
    -->
    <!--
       <test.jar>
          <source_dir_jar>@SPLEBASE@/etc/lib</source_dir_jar>
          <dest_folders>
             <dest_folder_1>@SPLEBASE@/splapp/applications/XAIApp/WEB-INF/lib</dest_folder_1>
             <dest_folder_2>@SPLEBASE@/splapp/applications/root/WEB-INF/lib</dest_folder_2>
             <dest_folder_3>@SPLEBASE@/splapp/businessapp/lib</dest_folder_3>
             <dest_folder_4>@SPLEBASE@/splapp/mpl/lib</dest_folder_4>
             <dest_folder_5>@SPLEBASE@/splapp/standalone/lib</dest_folder_5>
          </dest_folders>
          <list_of_AND_conditions>
                <condition_1>SPLWAS=WLS</condition_1>
                <condition_2>DBNAME=TESTDB</condition_2>
          </list_of_AND_conditions>
          <list_of_OR_conditions>
                <condition_1>DBUSER=cisuser</condition_1>
                <condition_2>DBUSER=CISUSER</condition_2>
          </list_of_OR_conditions>
          <child_jvm_path>@SPLEBASE@/splapp/standalone/lib</child_jvm_path>
          <target_folder>base</target_folder>
       </test.jar>
    -->/Markus

  • Project in JAR does not want to run

    Hello,
    sorry my english is not very good.
    I ended a small application using rules business (with Drools) when I execute my project with Eclipse, everything works, my files are created. But when I execute the file JAR, there is no file of created,
    Where from comes the problem?
    My MANIFEST file
    Manifest-Version: 1.0
    Classpath: org.drools.eclipse_4.0.4.jar
    Main-Class: Lancement
    and Exception with the command java -jar
    C:\Documents and Settings\jcqbnt\My Documents>java -jar "Cr�er fichier d'erreurs.jar"
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/drool ===> Where is it?
    s/WorkingMemory
    at Lancement.go(Lancement.java:53)
    at Lancement$1.actionPerformed(Lancement.java:42)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
    ce)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    thanks for your help

    I know nothing about Drools but I am suspicious of the manifest Class-Path. The entry should be the jar file name, with a path relative to your jar file's location. I took a quick Google of drools and I am guessing that "org.drools.eclipse_4.0.4.jar" is not the jar file name you should be using.

  • [HELP] "streaming JAR is not found" during MapReduce with ORCH

    After I upgrade my ORCH-1.1 to 2.0, I got an error like this when execute MapReduce via R:
    DBG: 11:12:00 [ER] streaming JAR is not found at "/home/hadoop/hadoop-0.20.2/contrib/streaming/hadoop-0.20.2-streaming.jar"
    Error: execution aborted
    BTW, I have specified environment variable "*HADOOP_STREAMING_JAR*" and the file */home/hadoop/hadoop-0.20.2/contrib/streaming/hadoop-0.20.2-streaming.jar* exists.
    Could you please give some advice?
    Thanks.
    Edited by: 819378 on 2013-1-29 下午10:01

    After reading source code, I got a w/a. Using assign function to modify initial environment "streaming.lib": assign("streaming.lib", <PATH_JAR> , ORCHcore:::.orch.env)
    The difference between 1.1 and 2.0 is they have different variable names. In ORCH-1.1 the name is ORCH:::.orch.env. It changed to ORCHcore:::.orch.env in ORCH2.0.
    Maybe it's useful for people in the same situation like me.
    Sorry for bothering.

Maybe you are looking for

  • Data recognition during transfer of data from cube to cube.

    Dear All,         If I have 2 cubes in such a way that 2nd cube pulls data from the first cube. But in the first cube data is there till March 2007 and the second  has pulled data till february 2007. But in a certain incident the ticks in "Data Mart

  • I need to reset my security questions however there is no option to send a reset link to email address anyone help?

    I need to reset my security questions however there is no option to send a reset link to email address anyone help?

  • Error while using JARToolkit3D

    Hello All, I am getting the following error while using JARToolkit for a tracking application......In fact I am trying out the DemoJava3D example given by the JARToolkit itself, but still I am not able to run the program.....The error is as follows:

  • Ipad and movie purchases

    I started to download a movie directly to my ipad but lost the wifi connection. I recieved a notice on the ipad that I either need to connect to a wifi network or download to my computer. How is that done? Or do I have to repurchase from my computer?

  • Weblogic.rmic and ant integration issue

    I am trying to call weblogic.rmic compiler through a ant script and was sucessful in doing so and generating the stubs and skelton for my RMI implementation. But i also want to pass a system property value (in the example i am passing file=stdout usi