Jar file error: could not find main class. program will exit

I have created a jar file using following command
jar cfm MyProj.jar Manifest.txt richa\*.class
and I have included main class header in the Manifest.txt. The executable jar file is created but when I double click on it, it prompts an error Could not find the main class. program will exit.
Please help. Its urgent..
Thanks in advance

This simply state that jvm was unable to fine Main Class file.
I hope you have configured manifest file including your main file information and class path used by the project with proper package hierarchy,
as described in article
[https://java.sun.com/docs/books/tutorial/deployment/jar|https://java.sun.com/docs/books/tutorial/deployment/jar]
Edited by: Deepesh on Jul 13, 2008 4:58 AM

Similar Messages

  • Could not find main class program will exit error while installing Oracle Client 32 bit on windows 7 32 bit OS?

    Hi Experts,
    When I am installing Oracle client 32 bit software on Windows 7 32 bit I am getting error as "could not find main class program will exit"
    I have tried installing latest Java software 7 also JDK 1.6.0_34 still I am getting the same problem below is my " oraparam.ini " details
    [Oracle]
    DISTRIBUTION=TRUE
    SOURCE=../stage/products.xml
    LICENSE_LOCATION=
    BOOTSTRAP_COMPS="oracle.swd.oui:11.1.0.6.0,oracle.swd.oui.core:11.1.0.6.0,oracle.jdk:1.5.0.1.1"
    JRE_SCRATCH_LOC=jdk/jre
    JRE_MEMORY_OPTIONS=" -mx96m"
    DEFAULT_HOME_LOCATION=product\11.1.0\client
    DEFAULT_HOME_NAME=OraClient11g_home
    NO_BROWSE=/net
    NLS_ENABLED=TRUE
    BOOTSTRAP=TRUE
    EXT_JLIB=../stage/ext/jlib
    OUI_VERSION=11.1.0.6.0
    ## JRE_VERSION is only for Windows. This is to copy accessbridge dlls
    JRE_VERSION=1.4.2
    ACCESS_DIR=../install/access
    #SHOW_HOSTNAME=ALWAYS_SHOW shows the hostname panel always
    #SHOW_HOSTNAME=NEVER_SHOW does not the hostname panel
    #SHOW_HOSTNAME=CONDITION_SHOW shows the hostname panel on condition
    SHOW_HOSTNAME=NEVER_SHOW
    #THIN_JDBC_FILENAME is optional and defaults to classes12.jar
    #The value specified for this should be packaged with OUI, and should
    #be relative to <OUI expanded stagedir>/jlib/
    THIN_JDBC_FILENAME=classes12.jar
    #RUN_OUICA specifies the batch script name that needs to be run
    #The script is ouica.bat for win32, and ouica.sh for solaris.
    #If the value is not specified, then the OUICA script is not run
    RUN_OUICA=ouica.bat
    CLUSTERWARE={"oracle.crs","10.1.0.2.0"}
    SILENT_VARIABLE_VALIDATION=TRUE
    [Generic Prereqs]
    MIN_DISPLAY_COLORS=256
    [IMAGES]
    FILE1=images/billboards.gif
    LICENSE_LOCATION=license.txt

    Duplicates of the other two times you asked this question:
    https://forums.oracle.com/thread/2559093
    https://forums.oracle.com/thread/2558027
    (and this time, your question does not appear to have anything to do with this particular forum space, either)
    Duplicate is locked.
    Do not EVER multi--post.   That is extremely bad forum etiquette.

  • Uh oh...  ERROR "Could not find main class" BmpImageReader.class

    Ooopss.. i broke it... was working , but yep.. i broke it
    Class File Editor
    Source not found
    The source attachment does not contain the source for the file BMPImageReader.class
    You can change the source attachment by clicking Change Attached Source below:
    public class com.sun.imageio.plugins.bmp.BMPImageReader extends javax.imageio.ImageReader implements com.sun.imageio.plugins.bmp.BMPConstants
    Long list of constants follow.. blah blah
    Long list of methods follow.. blah blahUh I was able to compile, but not everytime I try I get this popped up... I was trying to load a bmp image and it worked.. i tried to load another and now this... now I can't even load the bmp that I had successfully done before.. so I removed the code that tried to load the bmp, but I still get this problem..

    Ah what the.. its working again.... odd.. very odd.. I don't know how to delete this thread , but go ahead you all mighty powerful moderators..
    Edit: Yeah I had a main function.. maybe I accidentaly deleted or added a bracket or something I don't know.. very strange..
    Message was edited by:
    Kurisu

  • Jar file could not find main class.. I cant see why?

    I have read loads of tutorials on this and it should be very straight forward but i STILL cant make a working jar file of my program.. please see if you can see anything wrong with what im doing..
    my program is one .java file that compiles perfectly, and is runnable both through eclipse and by using the command prompt.. i made a jar file using both eclipse and the command prompt, and neither worked.. every time i run it by double clicking it i get the error "could not find main class, program will exit". here is the contents of my jar:
    CorePackage\IPEmailer.class
    CorePackage\IPEmailer$1.class
    CorePackage\IPEmailer$SMTPAuthenticator.class
    META-INF\MANIFEST.MF
    the MANIFEST.MF file contains:
    Manifest-Version: 1.0
    Class-path: .
    Created-By: 1.6.0_02 (Sun Microsystems Inc.)
    Main-Class: CorePackage.IPEmailer
    (yes there is a blank line at the end)
    the class mentioned in 'Main-Class' has a main method that looks like this:
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new IPEmailer();
    }the program uses 2 external jar files:
    activation.jar
    mail.jar
    and reads a file called:
    ipemailer.ini
    and writes a file called:
    ip.txt
    the program has no GUI and is intended to run 'silently' in the background
    please help me understand what is wrong with this

    package CorePackage;
    import javax.mail.*;
    import javax.mail.Authenticator;
    import javax.mail.PasswordAuthentication;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class IPEmailer implements Runnable{
          * @param args
         String recipientsinput[]={""};
         String subject;
         String body;
         String server;
         String user;
         String pass;
         String from;
         String urlString = "http://www.whatismyip.org";
         String currentIP;
         String ipFromFile;
         boolean webFailed;
         long interval = 900000; //15 mins
         long oldInterval;
         Thread t = new Thread(this);
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              new IPEmailer();
         public IPEmailer(){
                         ..........etccould the problem be that the class is a thread? i cant see why it would be, but ive never made a jar where the main class also 'implements runnable'

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

  • Error:-could not find the main class programe will exit(Java virtual mach)

    Hi,
    i changed the mainfest file for an executive jar file(judge.jar) using the command on dos :-"jar cvfm judge.jar c:\judge\MAINFEST.MF -C judge/ ." , but when i run this jar file again after making changes in mainfest file it is not working. an error encounter like "could not find the main class programe will exit how to solve"(Java virtual machine launcher).please suggest me how to solve this error.
    Thanks
    Ashwani Gupta

    Hi,
    mainfest file has a entry like "main -class: judge.repository.corpus"
    please tell me the solution of this error i am doing internship in national university of singapore......and my project is related to data mining.I am using judge.jar when i extract this jar files i saw there was no main-class in manifest file so i change it and make it again jar file using dos command.please suggest me how i can reomove this error.
    Thanks in advance.
    Ashwani

  • JAR: - Could not find main class

    I'm sorry, I know this issue has been posted before but I am a bit confused with my situation.
    After making a jar on my computer, I run it, and the program loads and runs perfectly.
    However, when I try the jar on someone else's computer, it doesn't work, and gives the "could not find main class" message. The other computer has JRE but not JDK, so I don't know if that makes a difference.
    Anyways, my main class file is located in a package called hw2, and the whole project is located in a folder called HW2. So my class file is located in something like C:\School\HW2\hw2\Main.class.
    My Manifest.txt file is located in the \School\HW2 directory and has the following with a new line at the end:
    Main-Class: hw2.Main
    At the command prompt, I go to my C:\School\HW2 directory and I type the following to create the jar:
    jar cvmf Manifest.txt test.jar hw2\*.class
    My jar file has the following contents:
    META-INF/
    META-INF/MANIFEST.MF
    hw2/Bank.class
    hw2/GUIInterface.class
    hw2/Main.class
    Did I write the manifest.txt file correctly? Am I in the right directory when creating the jar file? Am I executing the jar command wrong? How come it works on my computer but not on someone else's?

    Are you certain you're executing the jar in the same way on both machines?
    For example, are you sure you're not executing the unjarred class files when you run on your local machine?

  • Can't find main class - program will end

    Dear forum readers,
    Recently upgraded from Win2k pro to XP pro .. installation ran to conclusion w/ no fatal errors BUT upon booting new system I now receive an error message "Java Virtual Machine Launcher can't find main class, program will end" .. I am not aware that this error is causing any problems BUT it is annoying and I'd like to be able to fix the problem so I don't have to close the error message at each startup .. please help!
    Thanks in advance, Larry

    Try this
    java -XbootClasspath/a -jar <<Prog name>>
    I think you are trying in windows XP.
    Also you need to modify if there are any other jars to be reference. For eg if a.jar is also required for this try as below
    java -XbootClasspath/a:a.jar -jar <<Prog name>>

  • Could not find Main Class while executing JAR

    Hello all,
    I am having a simple Jar file that contains one java class that merely displays a window. I am using NetBeans IDE to create the JAR file. When i execute this JAR file by double clicking on the file, it works fine on the machine. However, if i try to execute this same file on any other windows computer, it gives an error "Could not find the main class. Program will exit."
    In other words, the JAR file is only working on the computer that has NetBeans and JDK installed on. Not on any other machine. Although the other machines have the JAVA Virtual Machine installed.
    I would appreciated any help on this topic.

    I had the same problem (i.e. Message-Box with "Could not find the main class. Program will exit.")
    After insuring that the manifest contained a Main-Class: argument and that the argument pointed to the right class, I started the jar via java -jar myjar.jar and read the stacktrace, which is much better than the popup-window.
    In my case the error was, that the Main-Class could not be loaded due to another referenced class, which was not on the classpath. (i.e. it was not in the same jar-File and the manifest didn't include a Class-Path: argument.)
    After adding the correct Class-Path: argument in the manifest, the problem went away.
    I now have the following setup:
    myjar.jar and somethirdparty.jar in the same directory.
    myjar.jar contains a manifest which includes the lines
    Class-Path: somethirdparty.jar
    Main-Class: my.package.and.MainClassafter the normal Manifest-header.

  • Could not find main class. Program will now exit. *SIGH*.....

    At first I thought it was just my own programs that I created with netbeans that had this problem; however, even the demo programs under the sdk folder give me this problem when i try to run them. Virtual Machine Loader will just come up with pop up saying "Could not find the main class. Program will not exit"
    I am a fairly competent programmer, not new to java. But I am new to guis in java, and using netbeans to create them. The program I am creating gives me this error with javaw and with java it will tell me NoClassDef for grouplayout. I checked the manifest file it looks alright:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 10.0-b19 (Sun Microsystems Inc.)
    Main-Class: desktopapplication2.DesktopApplication2
    Class-Path: lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar lib/swing-layout-1.0.1.jar lib/ant-swing.jar lib/SwingSet2.jar lib/swing-layout-1.0.3.jar
    X-COMMENT: Main-Class will be added automatically by build
    }(brackets not included)
    I am sort of lost.... Do I need to install ant separately?
    I feel like there may be some classpath issues?
    I have java 1.6 update 4 and netbeans 6.0
    I am completely lost I have been working on fixing this for the past 2 or 3 days now, and reading up all the information.
    Note: This is just a standard desktop application.
    Also I just thought of something. If I have install the development kit do I also need to install the framework or whatever for 6.0 separately? Meaning installing the latest version of jvm. Sorry if this isn't clear i forgot what it is called.
    Sorry if this sounds like a beginner question or something, but I am going crazy. If i am having this much trouble running my own program i really hope distributing files won't be this much of a nightmare....

    Please become familar with resources at the NetBeans site. There are tutorials and FAQs that cover usage of NB, and how to do things like you're asking.
    See my reply in this thread for more information
    http://forum.java.sun.com/thread.jspa?threadID=5270931&tstart=0

  • Another "could not find main class"  thread

    Hello everybody
    I know there's tons of threads on this subject but none of them seem to be quite like mine.
    I'm trying to deploy an application that I developped with Jbuilder 2006 Enterprise (trial version). It automatically created the "ServerApp.jar" file and the manifest but when I try to run it I get the famous message: "Could not find the main class. Program will exit." My main class is "Application" and it's in a package called "serverapp".
    here's a copy of my manifest:
    Manifest-Version: 1.0
    Main-Class: serverapp.Application
    it has two extra lines at the end.
    I read on the other threads that I also needed a .bat file (don't know quite why) so I created one. It looks like this:
    @ECHO ON
    Set Path = C:\Program Files\Java\jre1.5.0_04\bin
    cd C:\Documents and Settings\Naby\My Documents\Travail\Synapco\BlackeBerry\ServerApp
    javaw -jar ServerApp.jar
    EXIT
    One last thing: when I run the .jar file from the command line using the syntax
    java -jar serverapp.jar
    I get this more detailled error message:
    C:\Documents and Settings\Naby\My Documents\Travail\Synapco\BlackeBerry\ServerAp
    p>java -jar serverapp.jar
    Exception in thread "main" java.lang.SecurityException: no manifiest section for
    signature file entry javax/mail/internet/AsciiOutputStream.class
    at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVe
    rifier.java:377)
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVeri
    fier.java:231)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier
    .java:176)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:233)
    at java.util.jar.JarVerifier.update(JarVerifier.java:188)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:318)
    at java.util.jar.JarFile.getInputStream(JarFile.java:383)
    at sun.misc.URLClassPath$JarLoader$1.getInputStream(URLClassPath.java:62
    0)
    at sun.misc.Resource.cachedInputStream(Resource.java:58)
    at sun.misc.Resource.getByteBuffer(Resource.java:113)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)
    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)
    I don't know what is going on here.
    Any help would be really appreciated
    Thanks.

    Thanks for the reply martin
    what jar file are you refering to? I only have one jar file wich is "serverapp.jar" and that's the one I want to run.

  • Could not find main class!

    I tried some code I got from a book I recently bought it compiled ok but when I tried to run it in JPadPro I got the Java Virtual Machine Launcher warning saying 'Could not find the main class. Program will exit!' As far as I can see there is a main method so I am not to sure what the actual problem is. I pasted the code below hopefully someone can help, Dave.
    * Copyright (c) 2000 David Flanagan.  All rights reserved.
    * This code is from the book Java Examples in a Nutshell, 2nd Edition.
    * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
    * You may study, use, and modify it for any non-commercial purpose.
    * You may distribute it non-commercially as long as you retain this notice.
    * For a commercial use license, or to purchase the book (recommended),
    * visit http://www.davidflanagan.com/javaexamples2.
    package com.davidflanagan.examples.datatransfer;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.datatransfer.*;
    * This program demonstrates how to add simple copy-and-paste capabilities
    * to an application.
    public class SimpleCutAndPaste extends Frame implements ClipboardOwner
        /** The main method creates a frame and pops it up. */
        public static void main(String[] args) {
         Frame f = new SimpleCutAndPaste();
         f.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) { System.exit(0); }
         f.pack();
         f.setVisible(true);
        /** The text field that holds the text that is cut or pasted */
        TextField field;
         * The constructor builds a very simple test GUI, and registers this object
         * as the ActionListener for the buttons
        public SimpleCutAndPaste() {
         super("SimpleCutAndPaste");  // Window title
         this.setFont(new Font("SansSerif", Font.PLAIN, 18)); // Use a big font
         // Set up the Cut button
         Button copy = new Button("Copy");                      
         copy.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) { copy(); }
         this.add(copy, "West");
         // Set up the Paste button
         Button paste = new Button("Paste");
         paste.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) { paste(); }
         this.add(paste, "East");
         // Set up the text field that they both operate on
         field = new TextField();
         this.add(field, "North");
         * This method takes the current contents of the text field, creates a
         * StringSelection object to represent that string, and puts the
         * StringSelection onto the clipboard
        public void copy() {
         // Get the currently displayed value
         String s = field.getText();                 
         // Create a StringSelection object to represent the text.
         // StringSelection is a pre-defined class that implements
         // Transferable and ClipboardOwner for us.
         StringSelection ss = new StringSelection(s);
         // Now set the StringSelection object as the contents of the clipboard
         // Also specify that we're the clipboard owner
         this.getToolkit().getSystemClipboard().setContents(ss, this);
         // Highlight the text to indicate it is on the clipboard.
         field.selectAll();
         * Get the contents of the clipboard, and, if we understand the type,
         * display the contents.  This method understands strings and file lists.
        public void paste() {
         // Get the clipboard
         Clipboard c = this.getToolkit().getSystemClipboard();
         // Get the contents of the clipboard, as a Transferable object
         Transferable t = c.getContents(this);
         // Find out what kind of data is on the clipboard
         try {
             if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
              // If it is a string, then get and display the string
              String s = (String) t.getTransferData(DataFlavor.stringFlavor);
              field.setText(s);
             else if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
              // If it is a list of File objects, get the list and display
              // the name of the first file on the list
              java.util.List files = (java.util.List)
                  t.getTransferData(DataFlavor.javaFileListFlavor);
              java.io.File file = (java.io.File)files.get(0);
              field.setText(file.getName());
         // If anything goes wrong with the transfer, just beep and do nothing.
         catch (Exception e) { this.getToolkit().beep(); }
         * This method implements the ClipboardOwner interface.  It is called when
         * something else is placed on the clipboard.
        public void lostOwnership(Clipboard c, Transferable t) {
         // Un-highlight the text field, since we don't "own" the clipboard
         // anymore, and the text is no longer available to be pasted.
         field.select(0,0);
    }

    Oh, no wonder I have such low "reading for comprehension" scores - that was a "package" statement, not an "import".
    Thing is, your class would compile with this package statement there - but, the interpreter wouldn't be able to find it, 'cause the compiled class would be in a package called com.davidflanagan.examples.datatransfer accoding to the class file, but your interpreter would be looking for the class in the default package (if that makes sense). If executed on the command line you would likely see something like:
    Exception in thread "main" java.lang.NoClassDefFoundError: SimpleCutAndPaste (wrong name: com/davidflanagan/examples/datatransfer/SimpleCutAndPaste)
    [pre]
    Lee                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java Virtual Machine. Could not find main class

    I am trying to install Oracle Data Access Components ODAC 11g 11.1.0.6.21
    on windows 2008. I get the dreaded could not find the main class. Program will ext.
    I have seen all the post, tried installing every conceivable Java version, removed all java version.
    Nothing works. Does anyone have THE solution for this on-going error?
    Thanks

    I fixed my problem by installed Oracle 11g ODAC and Oracle Developer Tools for Visual Studio 11.1.0.7.20

  • Problem with message: Could not find the main class Program will exit

    I don't get why this isn't working. Any help is appreciated.
    //Code start
    public class hello{
    public hello(){
    public static void main( String args[] ){
    System.out.println("Hello");
    //Code end
    I compile it as so:
    javac hello.javaIt compiles fine and I now have hello.class in my current directory, but when I type the following:
    java helloI get this:
    Exception in thread "main" java.lang.NoClassDefFoundError: hello
    Caused by: java.lang.ClassNotFoundException: hello
    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)
    Could not find the main class: hello. Program will exit.

    mring001 wrote:
    That worked. Thank you very much!Good. You should read [_Setting the class path_|http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html] that tells you more about what the classpath is and how to set it.

  • Could not find Main Class while running JAR   outside /dist directory

    Hello
    I can make jar on netbeans by clicking Shift+F11. But the problem occurs when I copy paste my jar file out of /dist directory. It only works at /dist directory. I think my way making jar is incorrect. Anyone knows a way to make runnable jar by NetBeans instead of Shift + F11

    Crossposted here:
    [http://forums.sun.com/thread.jspa?threadID=5369074]
    Don't do that.

Maybe you are looking for