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

Similar Messages

  • Execute jar file: "could not find the main class" program will terminate

    Hey,
    I am new to Java. I have started to make a small java program which supposed to help me at my studies to lean the Dominic Memory System. I have used the latest version of Netbeans 5.5.1 to build my program in. I have two problems which I cannot figure out how to solve, please help me.
    The first problem is that the java script I have made works when I compile it in Netbeans, but when I create a Jar file it does not work. I receive a pop up message in windows ?could not find the main class program will terminate? when I execute the jar file.
    The second problem I have is that I need to compare the strings generated by the "numbers" and "TIP" and if the numbers is not identical the numbers in the ?Center? JPanel should be highlighted as red.
    If anyone would like to clean up the code I would be pleased. I have copied quite a lot from anyone because of my one lack of knowledge.
    * GoListener.java
    * Created on 12. september 2007, 21:48
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package grandmaster;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Vector;
    import java.util.StringTokenizer;
    import java.awt.Color;
    * @author Computer
    public class GoListener implements ActionListener {
    private JTextField viewer;
    private JTextField TIP;
    private JTextField freq;
    private JTextField max_num;
    private Vector numbers;
    public GoListener(JTextField j,JTextField k, JTextField m, JTextField f, Vector n) {
    freq = f;
    max_num = m;
    viewer = j;
    numbers = n;
    TIP = k;
    public void actionPerformed(ActionEvent e){
    int time = Integer.valueOf(max_num.getText());
    int f = Integer.valueOf(freq.getText());
    if (e.getActionCommand() == "GO") {
    for (int i = 0; i< time;++i) {
    int number=0;
    number = (int)Math.floor(100*Math.random());
    while(number>51){
    number = (int)Math.floor(100*Math.random());
    if(number<=9){
    viewer.setText(" "+"0" + String.valueOf(number) + " ");
    } else{
    viewer.setText(" " + String.valueOf(number) + " ");
    viewer.paintImmediately(viewer.getBounds());
    numbers.add(number);
    try {
    Thread.sleep(f*1000);
    } catch (Exception exp) {
    viewer.setText(" XX ");
    viewer.paintImmediately(viewer.getBounds());
    if (e.getActionCommand() == "VIEW") {
    try {
    //int numb = Integer.valueOf( TIP.getText() ).intValue();
    StringTokenizer tokenizer = new StringTokenizer(TIP.getText(), " ");
    String[] split = null;
    int tokenCount = tokenizer.countTokens();
    if (tokenCount > 0) {
    split = new String[tokenCount];
    for (int current = 0; current < tokenCount; current++) {
    split[current] = tokenizer.nextToken();
    viewer.setText(" " + String.valueOf(numbers) + " ");
    // k=numbers(1);
    /*while(c<i){
    String.valueOf(k).equals(split[1]);
    c++;
    TIP.setText(" " + split[2] + " ");
    } catch (Exception exp) {
    try {
    //string testit = numb.toString();
    //String str = "" + numb;
    //viewer.setText(str);
    //viewer.setText(numbers.toString());
    numbers.clear();
    } catch (Exception exp) {
    * Main.java
    * Created on 12. september 2007, 21:07
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package grandmaster;
    import java.util.Vector;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.JButton;
    import java.awt.*;
    import grandmaster.GoListener;
    * @author Computer
    public class Main extends JFrame {
    private JTextField viewer;
    public JTextField TIP;
    // private TextInputPanel TIP;
    private Vector numbers;
    /** Creates a new instance of Main */
    public Main() {
    numbers = new Vector();
    JPanel p = new JPanel(new GridLayout(0,4));
    JButton go = new JButton();
    JButton view_num = new JButton();
    go.setText("Go!");
    go.setVisible(true);
    go.setActionCommand("GO");
    view_num.setText("VIEW");
    view_num.setVisible(true);
    view_num.setActionCommand("VIEW");
    JTextField max_num = new JTextField();
    max_num.setText("5");
    JTextField freq = new JTextField();
    freq.setText("1");
    viewer = new JTextField();
    viewer.setText("XX");
    TIP = new JTextField("");
    p.add(go);
    p.add(max_num);
    p.add(freq);
    p.add(view_num);
    getContentPane().add(p,BorderLayout.NORTH);
    getContentPane().add(viewer,BorderLayout.CENTER);
    getContentPane().add(TIP,BorderLayout.SOUTH);
    setSize(200,200);
    GoListener g = new GoListener(viewer,TIP,max_num, freq, numbers);
    go.addActionListener(g);
    view_num.addActionListener(g);
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    Main window = new Main();
    window.setVisible(true);
    }

    NetBeans questions should be posted to the NB site. It has mailing lists and associated forums.
    This tutorial from the NB site addresses running programs outside of NB
    http://www.netbeans.org/kb/articles/javase-deploy.html
    When you compare objects, use ".equals()" and reserve == for comparing values.

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

  • JAR  file:      could not find the main class.

    I have been working with Java satisfactorily for about two years.
    Installed a bigger hard disk.
    Installed Windows XP.
    Downloaded java.
    Downloaded java jdk 1.6.0_07
    Downloaded java3d 1.5.2
    Downloaded Eclipse Ganymede.
    A new project, a new class with an existing and working java file. It did function in eclipse.
    Generated a jar file with:
    Export \ JAR FILE \ select files and the destination for the Jar file .....
    ... next...next filled the field Main Class
    This generates the jar files, which have worked before.
    And now the error: could not find the main class.
    Thand you for your help.

    Executing a jar file means it will not read from the CLASSPATH environment variable. I learnt this the hard way a few weeks ago and I had to resort to different measures to work around it.
    Your problem does sound weird, but check that the last line in your manifest file is a new line. If it's not, the manifest is not read and parsed correctly.
    To test, do this: remove everything from the manifest that you don't need, except the Manifest-Version and Main-Class attributes. Make sure the last line is a new line, and see if it works.
    Cheers

  • Running JAR files (Could not find the main class error)

    Hi all,
    I'm having a bit of a problem with my app. I created an application with the current Netbeans edition, containing multiple .class files, and a few .jar libraries that are needed too.
    Now I'm having problems with running the .jar that the Netbeans creates, so I figured I'd make a one on my own.
    Okay, this is what I have going on:
    C:\MyApp\ <--- root for the application
    C:\MyApp\src\ <--- this is where the .class files are
    C:\MyApp\lib\ <--- here are the .jar libraries which are needed
    C:\MyApp\jar.exe
    C:\MyApp\Manifest.txt
    Now I have a couple questions.
    1. Is it ok that the .class files all have a "package MyPackage; " thing in the beginning?
    2. How should I proceed on making the Manifest.txt file correctly? I have tried various different outputs and read a few topics here from how it should be done, but I just can't nail it. Currently my Manifest looks like:
    Main-Class: MyPackage/Myapp
    Class-Path: lib/xxx.jar lib/xxx2.jar lib/xxx3.jar
    Any help would be appreciated! Thanks.

    Oh, almost forgot:
    3. The right way to create a jar? I used this:
    C:\MyApp\jar cmf Manifest.txt MyJar.jar src\*.class
    And system is Windows XP.

  • Could not find the main class error with executable jar

    Hello,
    I have troubles creating an executable jar file and I ran out of ideas how to solve it so I would appreciate some help.
    I have created a jar file with the export function in eclipse
    the Manifest.MF file contains:
    Manifest-Version: 1.0
    Main-Class: view.AppTennisViewI tried starting the file with a batch file which contains following code:
    @echo off
    javaw -classpath c:\TennisHSQLDB_GC2\tennisApp.jar
    @start javaw -jar tennisApp.jar
    exitthe batch file and the jar are both located in c:\TennisHSQLDB_GC2.
    When i try command line I get the same result.
    I also tried alternate statements such as SET CLASSPATH iso javaw -classpath and including the classpath in the manifest file but no luck. It keeps given me the error: could not find the main class. program will exit
    Anyone any suggestions for my problem?

    nevermind, found it.
    classpath in manifest was incorrect

  • Executable Jar:  Could not find the main class. Program will exit.

    I have a jar which contins the class Main.class.
    Following details are specified in the Manifest file.
    Manifest-Version: 1.0
    Main-Class: Main
    However, when I double click the jar file, I get the error...
    Could not find the main class. Program will exit.
    What could be wrong?
    Thanks in advance
    Sachin

    hi,
    i've got exactly the same problem: double clicking the archive ends with an error (can't find the main class) but working with the command line executes the file!??!
    does anyone know a solution?
    thanks

  • [Jar Executable] Could not find the main class. Progam will exit.

    Hello,
    I am a French person. Excuse me for my English who is not perfect.
    I seek to create an achievable "jar". I followed the instructions given in the url http://java.developpez.com/faq/java/?page=execution#creationJar, and on the site of Sun.
    I have today only one class which I posed in a specific repertory "Class".
    Appli
    |__Class
    |__Src
    |__META-INFThe contents of my "Manifest" is stored in repertory META-INF with the name "Commission2007.MF" and its contents are as follows:
    Manifest-Version: 1.0
    Created-By: 1.5.0 (Sun Microsystems Inc.)
    Main-Class: Commission2007
    .I've left the space line at the end of the file.
    Here the result of execution of my order "jar":
    C:\#Java Dev\2007_Commissionnements>jar cvfm Commission2007.jar META-INF/Commission2007.MF -C Class/ .
    manifest ajout�
    ajout : Class/./(entr�e = 0) (sortie = 0)(0% stock�)
    ajout : Class/./Commission2007.class(entr�e = 9060) (sortie = 4547)(49% compress�s)I controlled the assignment of the extension "jar" in "Working station = > Tools = > Files Option = > Files Type = > .jar Selection = > Advance =
    Open = > Change = >" C:\Program Files\Java\jre1.6.0\bin\javaw.exe "- gravel bank" %1 "% *". Thus not of problem on this side there!When I double click on the file "jar" lately created, I have the error message according to: "Could not find the main class. Progam will exit. " I do not understand the reason of this error. I consulted all the subjects on the treating Net of this subject but without result. I thus call upon you.
    Perhaps that the cause is in my code which however functions perfectly when I carry out it with the order: "Commission2007 java". The class "hand" is quite present to see the code below. You can find the totality of my code on the bond http://www.developpez.net/forums/showpost.php?p=1870361&postcount=74
    import �
    public class Commission2007 extends Frame implements ActionListener, WindowListener
         �
         // Construction de la class EdText
         // D�finition et affichage de la bo�te de dialogue
         Commission2007()
         �
         // D�finition d'une frame pour l'application et affichage de la
         // bo�te de dialogue
         public static void main(String args[])
              Commission2007 editer = new Commission2007();
              editer.show();
              editer.addWindowListener(editer);
    }I thank you in advance for your assistance.
    Cordially, Gilles.

    Salut,
    It has been my experience that it is never a good idea to name your .MF file anything else other than MANIFEST.MF.
    Try naming your .MF file MANIFEST.MF and rebuild your JAR.
    Bon chance.

  • Could not find the main class (with every jar)

    This isn't a developer question. I get the error Could not find the main class with every jar I try to open (for example the jar downloaded from https://gjar.dev.java.net/ gives the same problems - and I don't think there is something wrong with that JAR). It isn't a problem with the jar or MANIFEST because the same jar works fine on my laptop. So there is something wrong with my JRE installation, but what?
    I tried to remove and reinstall the JRE 6 Update 18 but that didn't work. When I run the JAR with command line java -jar "file.jar" it works fine, but if I dubbelclick on it I get the error message (and it's irritating me).
    I'm a bit desperate so I hope that someone here can help me ;)
    Thanks in advanced

    hai T.B.M ... Sorry to post here... I know that i posted my question in wrong thread..but i dont have another solution to contact with you.. I had seen your answers which are really excellent and helped to do my project..
    Now i am having very less time to complete my project and i am very new to JMF.. I am not getting output in JMF video capture ..please check the code and guide me where i gone wrong.......please pardon me once again to post here.. Heres my code
    import javax.media.*;
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.media.protocol.*;
    import java.io.*;
    import javax.media.control.StreamWriterControl;
    public class webcam implements ActionListener,ControllerListener
    boolean eomReached = false;
    boolean realized = false;
    JFrame f;
    BorderLayout bd1;
    CaptureDeviceInfo device;
    MediaLocator m1;
    Player player;
    Component videoScreen;
    JButton b1,b2;
    Processor processor;
    DataSource ds=null;
    DataSink fileWriter=null;
    JLabel status=new JLabel("");
    public webcam()
    try
    JFrame f=new JFrame();
    JPanel p =new JPanel();
    JPanel p1=new JPanel();
    device=CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
    m1=device.getLocator();
    System.out.println("1");
    processor.configure();
    processor = Manager.createProcessor(m1);
    processor.setContentDescriptor(new
    FileTypeDescriptor(FileTypeDescriptor.MSVIDEO));
    ds=processor.getDataOutput();
    player.addControllerListener(this);
    MediaLocator dest = new MediaLocator("file://foo.avi");
    fileWriter = Manager.createDataSink(ds, dest);
    fileWriter.open();
    ds.connect();
    ds.start();
    player=Manager.createPlayer(m1);
    player.addControllerListener(this);
    blockingRealize();
    videoScreen=player.getVisualComponent();
    b1=new JButton("START");
    b2=new JButton("STOP");
    bd1=new BorderLayout();
    p.setLayout(bd1);
    p1.add(b1);
    p1.add(b2);
    p.add("South",p1);
    p.add("East",videoScreen);
    f.getContentPane().add(p);
    f.setVisible(true);
    f.setSize(500,500);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    b1.addActionListener(this);
    b2.addActionListener(this);
    catch(Exception e){}
    public void actionPerformed(ActionEvent e)
    if(e.getSource()==b1)
    try{
    processor.start();
    player.start();
    fileWriter.start();
    catch(Exception e1){}
    if(e.getSource()==b2)
    try{
    player.stop();
    processor.stop();
    processor.close();
    fileWriter.close();
    catch(Exception e2){}
    public static void main(String args[])
    webcam obj=new webcam();
    public synchronized void blockingRealize() {
    player.realize();
    while (!realized) {
    try {
    wait();
    } catch (java.lang.InterruptedException e) {
    status.setText("Interrupted while waiting on realize...exiting.");
    System.exit(1);
    public synchronized void controllerUpdate (ControllerEvent event) {
    System.out.println("myPlayer generated "+event.toString());
    if (event instanceof RealizeCompleteEvent) {
    realized = true;
    notify();
    } else if (event instanceof EndOfMediaEvent) {
    eomReached = true;
    }

  • Error msg Could not find the main class.Program will exit. in jar execution

    Hello,
    I have created a jar so that I can used it in the webapp.
    but when I click on it it says "Could not find the main class.Program will exit."
    I searched a lot in the net and found that it has to do with the manifest file.
    I even updated the manifest file using the command "jar umf main.txt filefolderupload.jar" with the class name mention along with the package heirarchy.
    (pakage heirarchy in /,\ and .)
    I am using JDK 1.5 . and have Updated JRE 1.6.
    Also tried with extending the class with JApplet, but in vain.
    Kindly help me in the above mention issue.
    tia,
    Sarwa

    This post hints at a number of misunderstandings on your part, and raises a couple of important questions.
    Note that this 'simple question' has a complicated answer. Given the complexity of it, it might pay to add Dukes to it, ..a lot of Dukes.
    The important questions are.
    1) Does this file/directory uploader need to provide the end-user with a file dialog in which they can choose a local directory to upload, or will a multi-file chooser do?
    2) Does this uploader need to upload to foreign sites, or does it upload back to its own server?
    Looking at this table I prepared to describe the [uploader/local file access|http://pscode.org/test/uploader/fileuploader.html] possibilities, if the answers to the questions are 'multi-file chooser will do' and 'home site only', the best option is a sandboxed app. launched using webstart (JNLP) - option 5. If either of those questions go the other way, option 6 (digitally signed with extended permissions) is needed.

  • JAR "could not find the main class"

    I'm running applications under XP.
    In my profile:
    I have a lot of problems double clicking on a jar file.... it always gives me this error: "could not find the main class"...
    In other XP profiles:
    All jar files run properly!
    Help me!

    Is your manifest correct? Does it contain the line
    Main-Class: Application
    or
    Main-Class: package/Application
    in the main section of the manifest (case sensitive)? Can the interpreter find all the required class files?
    Stephen

  • Could not find the main class: oracle.ide.boot.Launcher.  Program will exit

    Hi,
    I have installed Oracle11g_win64_11gR1, Database and Client.
    The issue is unable to invoke "sqldeveloper", getting the following error message. Could you please help ?
    FYI. I have already downloaded and installed installed JRE and JDK.
    ie. C:\Program Files (x86)\Java\jre6\ and C:\Program Files\Java\jdk1.6.0_24, still did not work.
    C:\Users\oracle>java -version
    java version "1.6.0_24"
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
    Let me know, if you need more information. Here is the error message.
    Error Message
    =========
    (1) if I invoke sqldeveloper, directly from the location " C:\app\oracle\product\11.1.0\db_1\sqldeveloper\sqldeveloper\bin " using explorer, I do get error message
    "Unable to find a java Virtual Machine.
    To point to a location of java Virtual machine please refer to the Oracle9i JDeveloper Install Guide ( jdev/install.html)"
    (2) if I invoke sqldeveloper, directly from the locationC:\app\oracle\product\11.1.0\client_1\sqldeveloper, it prompts me to enter "full path for java.exe".
    When I enter full path and continue, still it continue to prompt and ask the same input.
    (3) if I invoke sqldeveloper from from command prompt using the batch file "sqldeveloper.bat"
    C:\Users\oracle>C:\app\oracle\product\11.1.0\client_1\sqldeveloper\sqldeveloper\
    bin\sqldeveloper.bat
    C:\Users\oracle>java -Xmx512M -Xverify:none -XX:JavaPriority10_To_OSPriority=10
    -XX:JavaPriority9_To_OSPriority=9 -Doracle.ide.util.AddinPolicyUtils.OVERRIDE_F
    LAG=true -Dsun.java2d.ddoffscreen=false -Dwindows.shell.font.languages= -Dide.co
    nf="sqldeveloper.conf" -Dide.home.dir.name=.sqldeveloper -classpath ..\..\ide\l
    ib\ide-boot.jar;..\..\jdev\lib\xmleditor.jar;..\..\ide\lib\oicons.jar;..\..\..\j
    dbc\lib\ojdbc5.jar;..\..\jlib\jewt4.jar;..\..\jlib\share.jar;..\..\sqldeveloper\
    lib\jle2.jar oracle.ide.boot.Launcher
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/ide/boot/Launc
    her
    Caused by: java.lang.ClassNotFoundException: oracle.ide.boot.Launcher
    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)
    Could not find the main class: oracle.ide.boot.Launcher. Program will exit.
    OS
    ==============
    MS Windows 7 Home Premium
    sqldeveloper.conf
    ===================
    SetSkipJ2SDKCheck true
    IncludeConfFile ../../jdev/bin/ide.conf
    AddVMOption -Dapple.laf.useScreenMenuBar=true
    AddVMOption -Dcom.apple.mrj.application.apple.menu.about.name="SQL_Developer"
    AddVMOption -Dcom.apple.mrj.application.growbox.intrudes=false
    AddVMOption -Dcom.apple.macos.smallTabs=true
    AddVMOption -Doracle.ide.util.AddinPolicyUtils.OVERRIDE_FLAG=true
    AddJavaLibFile ../../jdev/lib/xmleditor.jar
    AddJavaLibFile ../../ide/lib/oicons.jar
    AddJavaLibFile ../../jlib/jewt4.jar
    AddJavaLibFile ../../jlib/share.jar
    AddJavaLibFile ../ide/jlib/xmlef.jar
    AddJavaLibFile ../../sqldeveloper/lib/jle2.jar
    AddJavaLibFile ../../sqldeveloper/lib/oracle.dbtools.logging.jar
    AddVMOption -Dsun.java2d.ddoffscreen=false
    AddVMOption -Dwindows.shell.font.languages=
    IncludeConfFile sqldeveloper-nondebug.conf
    SetJavaHome C:\Program Files\Java\jdk1.6.0_24
    Edited by: sivapara on Feb 16, 2011 1:08 PM

    I was able to resolve this issue by performing following.
    1. Go to the location where sqldeveloperW.exe is being executed from.
    2. You will find a file sqldeveloper.conf in that location. Edit this file and change the value of IncludeConfFile to point to actual place. For me following were old and new values.
    OLD (Wrong) : IncludeConfFile ../../jdev/bin/ide.conf
    NEW (Correct) : IncludeConfFile ../../ide/bin/ide.conf
    After making above change in the sqldeveloper.conf file. Save and close it. Restart SQLDeveloper. You will not get the error anymore.
    Thanks
    Ravi

  • Could not find the main class : HelloWorldApp program will exit

    please help me
    i downloaded and installed jdk-6u13-windows-i586-p(1) from sun.java.com
    in my computer --> Advanced --> environment variables --> i had set
    user variable :
    variable value
    java_home C:\Program Files\Java\jdk1.6.0_13\bin
    System variable:
    path : C:\Program Files\Java\jdk1.6.0_13\bin
    after that i wrote a program
    * The HelloWorldApp class implements an application that
    * simply prints "Hello World!" to standard output.
    class HelloWorldApp {
    public static void main(String[] args) {
    System.out.println("Hello World!"); // Display the string.
    i saved in c:\ mywork
    i compiled it with
    javac HelloWorldApp.java and then
    java HelloWorldApp
    output / result also came
    but iam unable to create jar file . when it is created it is showing
    could not find the main class : HelloWorldApp program will exit
    i created jar file by following way
    i created
    manifest.txt
    Min-Class : HelloWorldApp and then
    start -->run--> cmd-->
    c:\mywork> jar cfm test.jar manifest.txt HelloWorldApp.class
    c:\ java -jar test.jar
    but it displays a message
    " could not find the main class : HelloWorldApp program will exit "
    please please please help me please 1000's of please help me

    Peter__Lawrey wrote:
    You have to specify the manifest with a special option (I think its was -M)
    Otherwise the jar will create one (even if you provide it)No, the text file passed as a parameter will be incorporated in the manifest file generated by the JAR tool.
    @OP: This will work:
    JarTest.java
    public class JarTest {
      public static void main(String[] args) {
        System.out.println("JarTest works!");
    }manifest.txt
    Main-Class: JarTest+(note there is an extra new line in the manifest.txt!)+
    Now execute these commands:
    javac JarTest.java
    jar cfm MyJar.jar manifest.txt JarTest.class
    java -jar MyJar.jar And on my machine, the string "JarTest works!" is displayed on the screen.
    And if you look in the MANIFEST.MF file inside your jar file (you can use almost any zip-utility for this), you will see the following:
    Manifest-Version: 1.0
    Created-By: 1.6.0_0 (Sun Microsystems Inc.)
    Main-Class: JarTestOr something similar.

  • Could not find the main class. Program will exit!

    I have created many Executable Jar files before, and this one I did the same. When I run the jar file, (Clicking on it) I get the "Could not find the main class. Program will exit!" error message. When I run the jar file through DOS I get this Stack trace:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/ControllerListener
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:246)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
    Any Ideas? I did a search on google, and looks like others have had this problem but found no answer.
    US101

    There could be several reasons for getting this "Could not find main class" error message. From your stack trace it looks like the class javax/media/ControllerListener is not in your class path. Make sure your manifest file has a line like this:
    Class-Path: pathToTheJarFileWithControllerListenerClass.jar otherJars.jar
    This error message is also generated whenever any static initialization errors out giving the misleading error message implying that there is something wrong with the main class. Prior to starting your main class, static initialization of any static variables takes place. In my case, I was initializing a resource bundle, and forgot to include the property file in my building of the jar file. Well this failed of course and the generic error message appeared. It took many long hours to figure out it didn't have anything to do with the manifest file or the main class itself.
    HTH,
    John Bender

  • Could not find the main class?

    I am getting a
    Could not find the main class. Program will exit!
    Error with 1.3, but its because there is a jar file missing from the class path. The main class is actually there. Took me 1/2 to figure that out. This must be an error in the java command. Anyone else notice this?

    Hi all
    I'm stuck in the same thing as well...not only am I having problem with the JAR file I created, I'm also having problem executing other's JAR files..
    For example, I created this JAR file with 'Main-Class: PrototypeTest' as it's header but when the JAR file is done and I tried to run it, it simply gives me the No Main Class Found error.
    Same thing happens when I downloaded this JAR file game from Virum's website and tries to run it...no can do either...
    So wondering...has anyone found the solution to this yet? I'm still looking but it is sure driving me crazy...

Maybe you are looking for

  • Auto Creation of Storage Location at the time of Goods receipt

    Dear All Please tell me how can i create storage location automatically at the time of Goods receipt. i already made the configuration in OMJ8 for movement type and required plant still, at the time of creating PO its not getting created.. Please adv

  • Issue in IP - Entering value for Characteristic object

    Hi Expert, I have a requirement where the input has to be unabled for characteristic objects through IP template. I did the development as per the blog: http://scn.sap.com/blogs/Christopher.sapbw/2012/12/25/master-data-planning-with-sap-integrated-pl

  • How do i get iTunes working again?

    I am running windows 7 64-bit on my PC and recently I have had problems with iTunes. When I click on the iTunes icon, it shows, that it is loading just for a split of a second and iTunes won't open. It only opens in safe mode. A few days ago I instal

  • Access/edit existing mobile me domain on iWeb on a new computer

    I recently had to change over to a different mac. I think I copied all the correct files I needed from my old mac. These files are now on my new mac. I need some help to find the best way to open up the iWeb software on the new mac and access/edit my

  • How can I package a custom block of HTML code to be inserted by clicking the insert panel

    Is there a way to package custom HTML code such as <figure> <img src="" alt="" /> <figcaption> Caption </figcaption> </figure> so that I can click a button on the insert panel and insert this code?