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.

Similar Messages

  • 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

  • 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

  • Help Me Urgent...Error: "Could not find the main class. Program will exit."

    Am using Eclipse 3.3.2
    I have a project called: SWDS
    Initially i have JDK1.6 installed in my system. At this time the project is running succesfully.
    But when i removed(uninstalled and environment path also removed) JDK 1.6 and installed JDK 1.5 and path also given.
    No changes are made in the project code.
    When I Run the project SWDS then showing an alert "*Could not find the main class. Program will exit*" and then getting error messages like:
    {color:#ff0000}java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at 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)
    Exception in thread "main"{color}
    Pleez help me how to rectify this error.

    The manifest file is missing from the project.
    I searched the net and read about the manifest file and I saw that it is supposed to be located in META-INF/MANIFEST.MF. I suppose that means project_root/META-INF/MANIFEST.MF, right ?
    I am asking this because I haven't got that much experience in Java and this is the first time I hear about a manifest file.
    Does anyone have any Ideea how I add a manifest file to a project with Eclipse SDK? I searched the menus and I didn't find anithing of such sort... o
    Does Eclipse have support for editing manifest files at all?

  • Could not find the Main Class. Program will exit. Eclipse w/ JDK 6 RC

    Hi all,
    I needed to upgrade to JDK 6 RC w/ Eclipse while encountering a java.lang.NullPointer exception.
    Now I would like to compile my code with the new VM. I set all preferences to VM Version 6.
    Now I have the following Error:
    Java Virtual Machine Launcher
    Could not find the Main Class. Program will exit.
    What do I do now? Attached you find the Error Message.
    Bye
    Gerrit
    ================================The System.error looks like:
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"

    i wouldn't report a nullpointer to sun unless you're fairly confident there's some sort of bug. if main() can't be found it sounds to me like a config issue. if nullpointer, sounds like a code issue. post the code if you want, but i don't think sun will help you debug this.

  • Could not find the main class. Program will exit. Manifest error?

    Hello
    Im trying to export my project from eclipse to a jar.
    The error comes from main..
         public static void main(String[]args){
              try {
                   // first tell SkinLF which theme to use
                   Skin theSkinToUse = SkinLookAndFeel.loadThemePack("tigerthemepack.zip");
                   SkinLookAndFeel.setSkin(theSkinToUse);
                   // finally set the Skin Look And Feel
                   UIManager.setLookAndFeel(new SkinLookAndFeel());
                   System.out.println("Skin loaded");
              } catch (Exception e) {
                   // take an appropriate action here
                   JOptionPane.showMessageDialog(null,e.getMessage());
              new testGUI();
         }Everything works fine without the try catch and everything inside, so that must be the problem.
    In the build path in eclipse I have added a external jar called "skinlf.zip".
    I also use a zip called "tigetthemepack.zip" but thats not in build path.
    Im woundering if all this trouble comes from the manifest:
    Manifest-Version: 1.0
    Main-Class: presentation.testGUIIm not good with manifest files, ive tried som tutorials but i dont get it, and i realy dont know if thats realy the problem.
    Can anyone help me out?
    Kind Regards
    HV

    Now I have created a completly new project just to show my example.
    Enitire program code:
    import javax.swing.JOptionPane;
    import javax.swing.UIManager;
    import com.l2fprod.gui.plaf.skin.Skin;
    import com.l2fprod.gui.plaf.skin.SkinLookAndFeel;
    public class example {
         public example(){
              JOptionPane.showMessageDialog(null,"Hello World!");
         public static void main(String[] args) {
              try {
                   // first tell SkinLF which theme to use
                   Skin theSkinToUse = SkinLookAndFeel.loadThemePack("tigerthemepack.zip");
                   SkinLookAndFeel.setSkin(theSkinToUse);
                   // finally set the Skin Look And Feel
                   UIManager.setLookAndFeel(new SkinLookAndFeel());
                   System.out.println("Skin loaded");
              } catch (Exception e) {
                   // take an appropriate action here
                   System.out.println(e.getMessage());
              new example();
    }If I extract the jar file, It only contains:
    ".classpath"
    ".project"
    "example.class"
    "META_INF/MANIFEST.MF"
    MANIFEST.MF containes:
    Manifest-Version: 1.0
    Main-Class: example

  • Could not find the main class. Program will fail

    Hi I have just downloaded jdeveloper latest 10.2.1 full production version and unzipped and installed.
    When i launch jdevw.exe it comes up with a pop up error saying "Could not find the main class. Program will fail"
    clickin ok launches jdeeloper.. i developed a sinple jsp file and try to run it, now it says that fatal error in messages.
    Help please..
    Ram

    Now a new error.
    Internal compilation error, terminated with a fatal exception
    I changed installation from c:\program files to c:\ drive .. i got rid of the pop up error !!
    but when I create a simple jsp file, in a new workspace/project.. and run it.. it doesnot launch OC4J..
    In the messages pallette it says
    Internal compilation error, terminated with a fatal exception
    in the jdev console..
    java.lang.NullPointerException
    at oracle.jdeveloper.model.JProjectConfiguration.getJdkClassPath(JProjec
    tConfiguration.java:484)
    at oracle.jdeveloper.model.JProject.getClassPath(JProject.java:743)
    at oracle.jdevimpl.webapp.jsp.JspQuickCompiler.translate(JspQuickCompile
    r.java:225)
    at oracle.jdevimpl.webapp.model.content.DocumentInfoManager$DocumentInfo
    Impl$BackgroundErrorCheckingTimerTask.run(DocumentInfoManager.java:919)
    at java.util.TimerThread.mainLoop(Timer.java:432)
    at java.util.TimerThread.run(Timer.java:382)
    Wht the hell is goin on folks.. is this tool that bad.. .. I just downloaded and trying to evaluate it for my company ..!!

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

  • "Cannot find the main Class. Program will exit."

    Hi, I created a program, and I am trying to distribute it to other people in my office. I tried using both NetBeans 6.8/6.9 and eclipse. I exported to a single jar file. When I run this single .jar file, it runs perfectly. I sent it to one of my coworkers, and the message "Cannot find the main Class. Program will exit." popped up. I then had IT update his Java to 6.20 and it worked. The problem is that this program must be distributed to over 100 people, and I cannot have them each update their Java individually, nor will IT update everyone's on their own. They all have Java 4.XX I believe. Is there any way around this error that only happens on older versions of java? I have checked my manifest file and what not, as I said it runs on computers with Java 6.

    AndrewThompson64 wrote:
    Do you mean Java 1.4? It is best to be sure, so point some of the target machines at this page(1) to check.Yes, Sorry I meant 1.4.XX, I think they have 1.4.2_19.
    >
    >
    a) Ensure the code does not use functionality introduced in later versions, e.g. assertions, generics, for-each loops.. Using the [cross-compilation options of javac|http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#crosscomp-options] will warn of those.
    b) Ensure the code does not use any classes, attributes or methods that were not available in the earlier version, then use the cross-compilation options of javac when compiling. Actually the second will alert of the first, so long as the -bootclasspath parameter is used with an appropriate rt.jar.I believe that everything is ok, unless some of the swing functions cannot be used in 1.4. Besides the swing functions (which I am not sure about) everything should be able to be used in 1.4
    Thank You

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

  • Can not start WebLogic in Eclipse. Error: "Could not find the main class."

    I have installed Eclipse 2.0 and WebLogic Server 6.1. and the WebLogc plug in from GENUITEC (and jdk1.3.1_04, on Win2K Server). After I have done the configuration, the WebLogic start/stop buttons are integried into the Eclipse Toolbar, but when I click on the start button to start Weblogic, it pops up a dialog box "Java Virtual Machine Launcher" with message: "Could not find the main class. Program will exit!"
    Starting WebLogc Server from the Start panel works fine.
    Does any one have seen this before or have a suggestion what I should do?
    Many many thanks in advance.
    Huan

    Weblogic must be started with a full JDK; otherwise
    JSPs and dynamic EJB stubs could not be deployed. The
    error message
    indicates you are attempting to use a JRE. Configure
    Eclipse JRE to point to a JDK. The product
    documentation will help you with this process. It does not work for me. :-(
    I have tried JDK 1.3.1 and 1.4.1: same result: I get a "Could not find the main class: Program will exit"
    For free expert support please consider contacting
    Genuitec at [email protected] If just want any
    answer ask a newsgroup.
    WayneI'll try the support at '[email protected]' :)
    Michel
    Michel Szybist
    [email protected]
    Fax: +33 (0)173729897
    SMS: http://www.szybist.net/

  • Could not find the main class in Eclipse

    Hey,
    I've been working with Java for a few years now, but I recently set-up a new Eclipse-environment and now my Application won't run...
    "Could not find the main class. Program will exit."
    If I compile and run the source myself it works fine, so it must be a setting in Eclipse somewhere...
    It doesn't work, even when I put the class in the default package...
    It must be something very stupid, but I can't seem to find out what the problem is :(

    It was only the basic Hello-World-concept;
    public class Game extends JFrame {
         /** A default SerialVersionUID */
         private static final long serialVersionUID = 1L;
         public Game() {
              addKeyListener(new GameController());
              MainView view = new MainView(...);
              add(view);
          * @param args The game-options
         public static void main(String[] args) {
              Game spel = new Game();
              spel.setSize(1024, 768);
              spel.setTitle("Java Rally");
              spel.setResizable(false);
              spel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              spel.setVisible(true);
    }

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

  • 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

  • Installer problems - Could not find the main class

    Hello
    I am trying to install openmq on vista and having problems. I've had the same problem with a nightly build of 4.3 and stable 4.2 build. The install kicks off fine until I get to the part where the install happens and then I get:
    Java Virtual Machine Launcher : Could not find the main class. Program will exit
    I have several sun JREs/JDKs installed and have tried all of them, the installer itself is not impacted:
    jre 1.7.0
    jdk 1.7.0
    jre 1.6.0.7
    jre 1.6.0.7 and jre 1.6.0.7
    Am I missing something obvious or is there a way of installing without the java installer ?
    Much obliged
    Edited by: Alphawave on Oct 14, 2008 11:39 AM

    Hi,
    I've seen this error before on vista. In the past the users saw this message when they didn't have write permission on the directory they were installing to. Even with administrator privileges, they still need write permissions.
    A quick test is to:
    login as the user you are installing as.
    cd to the directory you are installing into.
    touch foo // to see if you can write to the dir.
    Thanks.

Maybe you are looking for

  • HT5429 What happened to street view?

    Is street view not available in maps with iOS6?

  • How to make a live curve in photoshop.

    Hi everyone, I just posted a video on youtube showing how to make a live curve. You can check it out here How to make a Live Curve in Photoshop - YouTube I'm very curious about your opinions:)

  • Embed a video in Muse?

    Can I embed a video in Muse, and I can upload to ftp to the Internet?

  • 2004s BI & SEM-BCS 6.0 in one System?

    Hi, Rumors say you should keep SEM out of your central BI and give it its own BI, to avoid painful patch/release dependencies. Should the SEM-BCS be installed on a separate system, because of patch interdependencies with the central BI? If yes, does

  • BPC Export data with filter

    Hello. It is necessary to export BPC transactional data by means of a standard export chain. How can I to customize filter use for export? Order my actions: 1.Run the Export package with Data Manager.  2.Choose a file name. 3. Choose the dimension. I