LogFactory in an Executable jar

Hi all,
I have an executable jar which throws an error when I try to set it going. I'll try to include all the details but shout if I've left anything out.
First, the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at aib.dos.aml.email.SecureEmailSystem.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 moreSo I made sure to include the commons-logging jar in my class-path in my manifest file (via ANT):
<manifest file="MANIFEST.MF">
<attribute name="Main-Class" value="aib.dos.aml.email.SecureEmailSystem"/>
<attribute name="Implementation-Version" value="${version.num}-b${build.number}"/>
<attribute name="Built-Date" value="${TODAY}"/>
<attribute name="Class-Path" value="lib/commons-logging-1.1.jar;lib/activation.jar;lib/bcmail-jdk14-128.jar;lib/bcprov-jdk14-128.jar;lib/commons-dbutils-1.1.jar;lib/mail.jar"/>
</manifest>The ant script builds the jar ok but when I try to run it, it looks like it can't find the class on the classpath. The jars are indeed in a folder called "lib" btw. The command I use to try an run the jar is: java -jar ses.jar
The above ANT command comes out as the following in the actual Manifest file:
Class-Path: lib/commons-logging-1.1.jar;lib/activation.jar;lib/bcmail-
jdk14-128.jar;lib/bcprov-jdk14-128.jar;lib/commons-dbutils-1.1.jar;li
b/mail.jar
If anyone can throw any light on the subject that'd be great,
Cheers,
Illu
EDIT: Also, this works in RAD IDE as an app but after I make the jar via the cmd window, the jar doesn't work anymore.
Edited by: Illu on Mar 27, 2008 10:53 AM
Edited by: Illu on Mar 27, 2008 10:56 AM

kajbj wrote:
Your Class-Path entry is wrong. You should use space and not ";" as delimiter between different entries.
See http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
KajThanks a million, Kaj, have some dukes :)
Can't believe I spent so much time on something that easy. Dunno where I dreamt up the ';' delimiter so... ah well!
Illu

Similar Messages

  • Links not working in executable jar

    I have a problem with my java application
    html and images files do not work in executable jar
    though the application works normally
    I tried some suggestion but I received an exception thread indicating problem at
    ImageIcon iChing = new ImageIcon(imageURL);
    Please could you help me thank you so much
    here is the class
    public class Main extends JFrame
    * objects required for the GUI: JFrame,JLabel, JButton, ImageIcon, JPanel,
    * Dimension
    private static final long serialVersionUID = 1L;
    JButton jbEnter;
    ImageIcon iChing, logo;
    JPanel buttonPanel, ImagePanel;
    JLabel jlbIching;
    Dimension dim;
    URL imageURL;
    File fileName;
    // Class constructor to create the GUI
    public Main()
    Container container = getContentPane();
    URL imageURL = this.getClass().getClassLoader().getResource("src/myFiles/iching.gif");
    ImageIcon iChing = new ImageIcon(imageURL);
    jlbIching = new JLabel(iChing);
    // button to go to the Title class
    jbEnter = new JButton("Enter ");
    jbEnter.setBorderPainted(false);
    jbEnter.setFont(new Font("Edwardian Script ITC", Font.BOLD, 42));
    jbEnter.setBackground(new Color(0, 0, 50));
    jbEnter.setForeground(Color.YELLOW);
    jbEnter.addActionListener(new ActionListener() {
    // method to render the current frame invisible and trigger the
    // Welcome Menu
    public void actionPerformed(ActionEvent e)
    setVisible(false);
    // this line does not work...............
    new Title();
    } // close the actionPerformed(ActionEvent e) Method
    }); // close the addActionListener(new ActionListener() method
    // Panel holding the decorative image and Button
    ImagePanel = new JPanel();
    ImagePanel.add(jlbIching);
    ImagePanel.setBackground(new Color(0, 0, 50));
    buttonPanel = new JPanel();
    buttonPanel.add(jbEnter);
    buttonPanel.setBackground(new Color(0, 0, 50));
    // setting up of the panels position
    container.add(ImagePanel, BorderLayout.CENTER);
    container.add(buttonPanel, BorderLayout.SOUTH);
    dim = Toolkit.getDefaultToolkit().getScreenSize();
    dim.width = dim.width / 2 - 300;
    dim.height = dim.height / 2 - 250;
    setBounds(dim.width, dim.height, 400, 400);
    setSize(600, 500);
    setResizable(false);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //To set the icon for the application. Top left hand corner.
    //this.setIconImage(Image);
    setIconImage(new ImageIcon("src/myFiles/ichingRose.gif").getImage());
    } // close the Constructor
    * the main method for the program.
    * @param args
    * The command-line arguments.
    public static void main(String[] args)
    new Main();
    } // close the main method
    } // close the Main class

    Thank you very much for your quick reply and really hope you can help me a little more
    it's so frustrating
    I do not really know about the relative path but here is my xml file
    <?xml version="1.0" encoding="UTF-8" ?>
    <project default="jar">
    <!-- Compile and zip the source code into a jar -->
    <target name="jar">
    <!-- Make the folders we'll need -->
    <mkdir dir="ant"/>
    <mkdir dir="work"/>
         <mkdir dir="ant/myFiles"/
    <!--
    Compile all the .java files into .class files
    debug = yes Include debug information in the .class files
    destdir Where to put the .class files
    source and target Use Java version 1.6.0_06
    -->
    <javac
    debug="yes"
    destdir="ant"
    source="1.6"
    target="1.6">
    <!-- Folders that have trees of .java files to compile -->
    <src path="src"/>
    </javac>
         <copy todir="ant/myFiles"><fileset dir="src/myFiles"></fileset></copy>
    <!--
    Zip files together to make a jar
    jarfile Where to make the .jar file, overwrite something there
    basedir Find the files to zip in the jar here
    -->
    <jar
                   jarfile="work/BookOfChanges.jar"
    basedir="ant"
    >
    <!-- Write a manifest inside the jar -->
    <manifest>
    <!-- The class Java will run when the user double-clicks the jar -->
    <attribute name="Main-Class" value="iChing.Main"/>
    </manifest>
    </jar>
    </target>
    </project>

  • I dont see the point of using Ant Build compared to executable Jars?

    I always think that to complete a project you successfully build it. And i thought that building is done automatically if you create an executable JAR? So what is ANT for?
    Arent Executables is the same as building your project?

    paulcw wrote:
    They are all unnecessary for a single person doing small projects (although often still necessary).I assume you meant "(although often still useful)".
    And furthermore you may find that the vast majority of your time programming professionally isn't the programming, but just managing these other aspects.It is a good day for me when that is not the case ;-)
    There should be a class in university: "industrial practices". It would have little or no CS theory but all the stuff that you learn the first year on the job (often painfully).The company I work in really likes to hire young developers, which often means that they come right from school (gladly, we have some good IT-centric schools in the area). They usually get some introduction in some of these aspects in school (usually mostly version control, bug tracking and a little bit of automated builds). But even if they heard about them, used them for a simple project and get the general idea, they still don't believe them to be necessary until they see what a pain in the back it can be not to have all that in a medium-sized project.

  • Adding a jar to the classpath of an executable jar (mixing -jar and -cp)

    Hello,
    frankly I hesitated over posting this to "New to Java"; my apologies (but also, eternal gratefulness) if there is an ultra-simple answer I have overlooked...
    I integrate a black-box app (I'm not supposed to have the source) that comes packaged as an executable jar (with a Manifest.MF that specifies the main class and a bunch of dependent jars), along with a few dependent jars and a startup script. Long story short, the application code supports adding jars in the classpath, but I can't find a painless way to add a jar in its "classpath".
    The app's "vendor" (another department of my customer company) has a slow turnaround on support requests, so while waiting for their suggestion as to how exactly to integrate custom jars, I'm trying to find a solution at the pure Java level.
    The startup script features a "just run the jar" launch line:
    java -jar startup.jarI tried tweaking this line to add a custom jar in the classpath
    java -cp mycustomclasses.jar -jar startup.jarBut that didn't seem to work ( NoClassDefFound at the point where the extension class is supposed to be loaded).
    I tried various combination of order, -cp/-classpath, using the CLASSPATH environment variable,... and eventually gave up and devised a manual launch line, which obviously worked:
    java -cp startup.jar;dependency1.jar;dependency2.jar;mycustomclasses.jar fully.qualified.name.of.StartupClassI resent this approach though, which not only makes me have to know the main class of the app, but also forces me to specify all the dependencies explicitly (the whole content of the Manifest's class-path entry).
    I'm surprised there isn't another approach: really, can't I mix -jar and -cp options?
    - [url http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html]This document (apparently a bible on the CLASSPATH), pointed out by a repited forum member recently, does not document the -jar option.
    - the [url http://download.oracle.com/javase/tutorial/deployment/jar/run.html]Java tutorial describes how to use the -jar option, but does not mention how it could play along with -cp
    Thanks in advance, and best regards,
    J.
    Edited by: jduprez on Dec 7, 2010 11:35 PM
    Ahem, the "Java application launcher" page bundled with the JDK doc (http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html) specifies that +When you use [the -jar] option, the JAR file is the source of all user classes, and other user class path settings are ignored+
    So this behavior is deliberate indeed... my chances diminish to find a way around other than specifying the full classpath and main class...

    I would have thought that the main-class attribute of the JAR you name in the -jar option is the one that is executed.Then I still have the burden of copying that from the initial startup.jar's manifest. Slightly less annoying than copying the whole Class-path entry, but it's an impediment to integrating it as a "black-box".
    The 'cascading' behavior is implicit in the specification
    I know at least one regular in addition to me that would issue some irony about putting those terms together :o)
    Anyway, thank you for confirming the original issue, and merci beaucoup for your handy "wrapper" trick.
    I'll revisit the post markers once I've actually tried it.
    Best regards,
    Jérôme

  • Class not found error while executing jar file

    I have written a java code in which i am connecting to database....when i run the class file using......java class_filename it works........
    but when i run the jar file using .......java -jar jar_name ...yi gives me the error as 'Class not found'......
    can anybody help me please......
    Thanks and Regards,
    Siddhesh

    that class is part of jar file.....in classpath i have included zip files for jdbc ...to get databse connection.....and the jar being executed ................still it gives the error ClassDefnotfound which i think is due to database connection problem.....the exception is raised while.....
    Class.ForName("Driver_name").newInstance();/ This driver is present in zip files that i have added in classpath....
    above statement doesn,t giv error while i execute the class file............but exception while executing jar file only..
    Thnaks and regards,
    siddhesh

  • Why -jar option used to install a software which is in executable jar file?

    Hi all,
    i have a query, i have a generic installer which is used to install the oracle weblogic 10.3 software in unix platform(i.e., which is in .jar extension) which is executable jar file.
    To install this software which have to use -jar option to install
    java -jar net_server<version>_generic.jar
    my question that why we use -jar option to install or to extract the software
    can any one clarify my doubt...
    thanks in advance
    abhi
    Edited by: sumanth_abhi on Jan 27, 2009 11:50 PM

    According to the Jar Guide (http://java.sun.com/j2se/1.4.2/docs/guide/jar/jarGuide.html)
    Executable Jar Files
    On Microsoft Windows systems, the Java 2 Runtime Environment's installation program will register a default association for Jar files so that double-clicking a Jar file on the desktop will automatically run it with javaw -jar. Dependent extensions bundled with the application will also be loaded automatically. This feature makes the end-user runtime environment easier to use on Microsoft Windows systems.
    The Solaris 2.6 kernel has already been extended to recognize the special "magic" number that identifies a Jar file, and to invoke java -jar on such a Jar file as if it were a native Solaris executable. A application packaged in a Jar file can thus be executed directly from the command line or by clicking an icon on the CDE desktop.
    Despite that every JAR file can be executed as a program if and only if the META-INF/Manifest.mf contains the Main-Class tag. This done through java -jar jarfile.jar
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Executable JAR file: Could not find the main class.

    Hello,
    I have a problem with making an executable JAR file.
    I have written a JAVA program that consists of five different classes of which User.java is the main class and I have saved a text document with Main-Class: User and a blank line after that.
    If I try:
    jar cmf MainClass.txt User.jar User.class Beheerder.class Operator.class Manager.class MaakVisueelSchema.class
    it makes a executable jar file which actually works! :)
    But when the Operator class trys to open the MaakVisueelSchema class the screen stays blank.
    I can run MaakVisueelSchema with java MaakVisueelSchema.
    So I tried to make an executable JAR that consists only of MaakVisueelSchema, the same way as I did for User:
    Main-Class: MaakVisueelSchema
    jar cmf MainClass.txt MaakVisueelSchema.jar MaakVisueelSchema.class
    Then I get the error message:
    Could not find the main class. Program will exit.
    from the Java Virtual Machine Launcher.
    The big difference between MaakVisueelSchema and the other classes is that MaakVisueelSchema contains a PaintComponent method and an ComponentListener. Is it possible that one of those creates the error?
    Can anyone help me with this problem?
    Thanks in advance!
    Bye!

    Yes,
    I tried:
    jar xvf MaakVisueelSchema.jar
    and it returns:
    META-INF/
    META-INF/MANIFEST.MF
    MaakVisueelSchema.classN/G. You need to manually create a manifest file in a text editor, have it point to your main class, and enter it in your jar command as an argument.

  • How can I add image files to a executable jar file ?

    Could you tell me how can I add image files to executable jar file ?
    package structure:
    ../com/Main.class
    ../images/..

    Please don't cross post, and read this
    http://forum.java.sun.com/thread.jsp?forum=31&thread=271751
    I've answered the question in the New To Java thread.

  • Add classpath in an executable jar file

    an executable jar file contains a manifest file with entry main-class: MyApplicationClass.
    if we double click the jar file on Windows OS, main class is loaded.
    my question is:
    if classes in he jar file use classpaths which are not default, how to add those classpaths into manifest file to tell classes to use those classpaths?
    it is similar to command line:
    java -classpath c;\mypackage; .......; MyApplicationClass

    Thanks, i will try soon.
    here is another Q.
    if i need to add tools.jar (JDK lib) as classpath in manifest file, it is as following in my PC
    d:\install\java\jdk14101\lib\tools.jar.
    but my customers install JDK in different path (should be considered as unknown), how to add it as entry Class-path for all customers?

  • FileWriter in executable jar

    I have a problem to read/write textfiles inside an executable jar.
    The problem exists when the files are included in the jar.
    E.g. writing to files outside the jar is fine and currently my solution is to keep them that way.
    At first I also had a problem pointing to images in the
    jar-file but it worked with something like the following:
    img=java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource("example.gif"));
    I tried the same approach to the FileReader like this:
    FileReader fr=new FileReader(getClass().getResource("example.dat").toString());
    The application compiles fine but does not find the file.
    Please share your expertise with me.

    You have to use external files or play with the java.util.jar package - there is not support for writing things directly to a jar in the java.io package.

  • Large project in JBuilder 2007... How do I create an executable JAR?

    First, I've googled quite a bit and keep getting thiings about "Jbuilder Application Wizard", etc... Well, I don't see any "wizard" menu in the version of JBuilder I'm using!
    I'm using JBuilder 2007 Enterprise edition, however it's a trial version apparently. I'm not sure if that matters, and perhaps the functionality was taken out with the trial version..
    Anyway, the issue is that I have a multi class (with one main function) program that I want to run (it's a command line based application) as an executable JAR file. The program uses LOTS of include statements including quite a few custom libraries ("external JARs") that I had to import.
    Basically I want the application to do exactly what it does now when I hit the ol' "RUN" button. Except I want to be able to run it from a batch file with "java -jar (or whatever) myProgram".
    Anybody have any experience with this type of thing?

    OK, here's what I've got:
    I've got a jar file that contains:
    1. a folder "importQD"
    2. a folder called META-INF
    3. a .classpath file
    4. a .project file
    Inside the importQD folder are my three .class files that are the classes I created myself.
    Inside the META-INF folder is the MANIFEST.MF file which looks like:
    Manifest-Version: 1.0
    Main-Class: importQD.ImportQDInside the .classpath file we have:
    <?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="C:\Programs\CMQualityDocumentImport\CMUploadInterface83.jar"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\DBCon.jar"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\SENAeMail.jar"/>
         <classpathentry kind="lib" path="C:\Programs\CMQualityDocumentImport\SENAFileHandler.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>NOTE: All of the paths point at the .jar files as they are located on the machine the final version will be running on.
    Inside the .project file we have:
    <?xml version="1.0" encoding="UTF-8"?>
    <projectDescription>
         <name>importOldQD</name>
         <comment></comment>
         <projects>
         </projects>
         <buildSpec>
              <buildCommand>
                   <name>org.eclipse.jdt.core.javabuilder</name>
                   <arguments>
                   </arguments>
              </buildCommand>
         </buildSpec>
         <natures>
              <nature>org.eclipse.jdt.core.javanature</nature>
         </natures>
    </projectDescription>Now, it would make sense to me that this should be all good to go, and that I should be able to run this via a command line now. When I try
    java -jar importQD.jar I get a ton of various errors such as "Exception in thread "main" java.lang.UnsupportedClassVersionError: importQD/importQD (unsupported major.minor version 49.0) + a nice stack trace with a bunch of java.lang and java.net references.
    What am I doing wrong?

  • How to create executable jar in eclipse using linking in compiler

    Hi,
    I have a project in Eclipse. I wrote already an ant build file for creating an executable jar which includes all project files.
    Now I want to create a second executable jar which is a subset of the project (a limited number of classes are necessary).
    I have a main class and I was looking for a way to generate a jar file which includes the main class and all the depending classes.
    Is there a way to do it? With ant or with another tool?
    Is it possible to compile a project given a main class, and include all depending classes?
    Regards,
    Biebel
    Edited by: biebel1975 on Jan 7, 2009 10:21 AM

    biebel1975 wrote:
    Some more information:
    When I compile all the classes, the jar file is +/- 3.5Mb inclusive the server side logic.
    The subproject I want to build, should be less then 1Mb (Only some screens and beans, no business logic ((only +/- 10% of the projects code) )).
    My question is: How can I create a executable jar with only the necessary class files which depends on the main class. (Linked with the imports).
    Is there a tool to do that? Can it be done with an ANT script? If so, how does the script looks?
    What are you talking about?
    You already said that you are using Ant.
    Ant uses script files.
    Since you have one with X items in it and you want something new with X-Y items in it the obviously it would make sense to construct an ant script that does less than the other ant script.
    The following provides a huge amount of information about Ant.
    [http://ant.apache.org/resources.html]
    Other than that no one can tell you want your Ant script will look like except that it will do less than the one that you already have.

  • Problem running my program only after making an executable jar...

    Hi everyone,
    I am having trouble running my program after creating an executable jar. The program runs fine until
    it is supposed to open a specific JFrame. I get the following error message as soon as the frame tries
    to open:
    Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.apache.xerces.parsers.SAXParser.<init>(Lorg/apache/xerces/xni/parser/XMLParserConfigurat
    ion;
    Has anyone ever seen this before?
    The strange thing is, this does not happen when I build and run the project under Eclipse.
    Any help or tips would be appreciated!
    Chris

    Roosh wrote:
    The strange thing is, this does not happen when I build and run the project under Eclipse.
    Any help or tips would be appreciated!Make sure you are using the same version of Java as you use with Eclipse.

  • Executable JAR containing images doesn't load them

    I'm using Netbeans 4.0 for developping a Java Application. This application is composed of 3 packages:
    - daemonexplorerv10: which contains the main class.
    - GUI: which contains classes I use to create the GUI of the application.
    - images: which contains GIF and PNG images used by the application. It also contains a class named ImageLoader which is used to load the images contained in the package. I will detail this class later.
    My main class, named Main.java, simply lauches the main JFrame of the application GUI. Here is the code of it's main method:
    public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    MainFrame.createAndShowGUI();
        }In the GUI package, I created a class named MainFrame which extends JFrame and is the main frame of my application GUI. Here is the code of it's method createAndShowGUI:
        public static void createAndShowGUI() {
            //Suggest that the L&F (rather than the system)
            //decorate all windows.  This must be invoked before
            //creating the JFrame.  Native look and feels will
            //ignore this hint.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            MainFrame main_frame = new MainFrame(main_frame_title);
            main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            main_frame.pack();
            main_frame.setVisible(true);
        }And here is the beginning of the code of it's constructor:
        public MainFrame(String title) {
            super(title);
            ImageLoader il = ImageLoader.getSingleton();
            ImageIcon application_icon = il.loadImage("application_icon.png");
            if (application_icon != null) {
                this.setIconImage(application_icon.getImage());
            else {
                System.out.println("Error - application_icon could not be loaded");
    ...As you see, MainFrame uses ImageLoader so as to customize the frame icon. ImageLoader follows the singleton pattern. It has a method called loadImage which returns an IconImage for a given image name. Here is the code of this method:
        public ImageIcon loadImage(String image_name) {
            ClassLoader cldr = this.getClass().getClassLoader();
            URL image_url = cldr.getResource("\\images\\"+image_name);
            if (image_url != null) {
                return new ImageIcon(image_url);
            else {
                return null;
        }For every image I want to use in my application, I use ImageLoader. It fetches the image thanks to the given name, provided that the image is placed in the package called images, or else the method loadImage returns null.
    So the MainFrame uses ImageLoader which fetches the image "application_icon.png" for the frame to set it as it's custom icon.
    My application runs perfectly well :)... as far as I run it through Netbeans launcher. But Netbeans also creates automatically an executable JAR file for each builded application. So I tried to lauch this JAR. Through this way, the application works, but all the images that should be loaded aren't!
    I unpacked the JAR so as to check if all the images are in it. Netbeans includes the images. Netbeans also creates a manifest file which seems perfectly correct.
    So I can't understand why my application runs without any images when I launch it through an executable JAR while it works fine (with all the images) when I lauch it through Netbeans.
    I checked many forums to find a solution. Using ImageIO doesn't or ToolKit doesn't solve the problem. It simply seems that the path of the package called images can't be found by the method getResource when this package is compressed in the JAR.
    P.S: I use J2SE Development Kit 5.0 and J2SE Runtime Environment 5.0.

    So ReinerP, I tried your code today in a little test application which has a single package containing two classes:
    - Main.java
    - JMainFrame.java
    Here is the code of Main.java:
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    //Suggest that the L&F (rather than the system)
                    //decorate all windows.  This must be invoked before
                    //creating the JFrame.  Native look and feels will
                    //ignore this hint.
                    JFrame.setDefaultLookAndFeelDecorated(true);
                    //Create and set up the window.
                    JMainFrame main_frame = new JMainFrame();
                    main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    //Display the window.
                    main_frame.pack();
                    main_frame.setVisible(true);
    }And here is the code of JMainFrame.java:
    public class JMainFrame extends JFrame {
        /** Creates a new instance of JMainFrame */
        public JMainFrame() {
            super();
            //load and set icon
            URL imgURL = JMainFrame.class.getResource("icon.png");
            ImageIcon img = new ImageIcon(imgURL);
            setIconImage(img.getImage());
    }As you said, it works :). It works when I run it through Netbeans launcher, and it also works when I run it through the Executable JAR Netbeans generated during the building of the application.
    So I adapted the code of the application I was talking about in the first post of this topic. I modified the code of the method loadImage in ImageLoader.java:
    public ImageIcon loadImage(String image_name) {
    //not working in JAR:  ClassLoader cldr = this.getClass().getClassLoader();
    //not working in JAR:  URL image_url = cldr.getResource("\\images\\"+image_name);
            URL image_url = ImageLoader.class.getResource(image_name);
            if (image_url != null) {
                return new ImageIcon(image_url);
            else {
                return null;
        }And it works well. Thanks again. However, I still can't explain why the use of class loader isn't undertood by the executable JAR.

  • Executable JAR sometimes could not find the main class.

    I have a little task, that seems to be trivial- but I have no idea how to solve the current problem.
    With a double click on my jar, a message comes up: JVM could not find the main class. Program will exit.
    The executable JAR is an export result from eclipse, with a manifest file that contains the right entry to the main class.
    But the curious thing is, that I have tested the little Swing-Application with 3 JRE versions: 1.4.2._06, 1.4.2_09 and 1.5 on Win2K and XP. Every time it works fine, but on one system it fails. (Normally it requires no external classpath settings, no path-entries to work.)
    The ugly system is Win XP with JRE 1.4.2_06 installed.
    Is there anybody with a good hint?
    Please let me know.
    Christiane

    OK, I ll try to explain it in other words:
    It is an executable jar file, with a manifest file that specifies the Main-Class. No other external files or jars or settings needed. Only a simple JDialog initialized from a parent JFrame.
    I d like to start it with a double click from the Win-Explorer, not from command line!
    As a result a dialog from "Java Virtual machine Launcher" displays
    "Could not find the main class. Programm will exit."
    My Problem is, I don t understand the launching process in depth. But I can reproduce the message with the following command:
    wrong:
    javaw -cp OrderAlertTest.jar OrderAlertParentDialog
    -> Error dialog appears
    correct:
    javaw -cp OrderAlertTest.jar apo.order.OrderAlertParentDialog
    -> OK
    Any idea?
    Christiane

Maybe you are looking for

  • Problem with v and w in a cube

    Hi, I have problem with 'v' and 'w' in an Analysis Services cube (SQL Server 2008R2). The example is employee number 'frvi' and 'frwi'. The cube summarize both employee's measures to employee number 'frvi'. And does not show the employee number 'frwi

  • Web-form errors/Its urgent

    ERROR: An error occurred. Your web form must capture customer name and email address. Please fix this issue and re-insert your web form on your web page. Why above error occues in folllowing form: <div class="mid-container col2-left-layout" id="rowan

  • K850 printer drivers and updated toolbox for win 7, pro 64 bit

    When will HP provide an updated driver and toolbox for the wide format inkjet printer?  This expensive printer is useless without the toolbox.  No way to align heads or check the accuracy of head alignment. If HP abandons this printer it will join th

  • Help Me! No Mater What I Do My Mac Just Won't Start Up

    I have a G3 and G5 Mac. On my G3 I have been getting problems. It started when I used a classic application. Classic acted strangely then quit I restarted my computer and I got the folder with the finder icon that turns into the question mark and bac

  • Executing HR Forms

    Hi, When trying to execute the Process from tcode HRASR_DT it is givig a dump, can some one help me to solve this?    The exception 'CX_PARAMETER_INVALID_RANGE' was raised, but it was not caught     anywhere along    the call hierarchy.    Since exce