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.

Similar Messages

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

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

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

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

  • 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

  • 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

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

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

  • 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

  • Another "could not find main class.

    I wouldn't ask this if I hadn't search the forum and spent hours trying to get this to work. Anyway, the jar file seems to be organized right and here is my manifest file (as set in Sun ONE Studio 4):
    Manifest-Version: 1.0
    Class-Path: xerces/xerces.jar xml-apis/xml-apis.jar xalan\xalan.jar bi
    n\ jdom\jdom.jar
    Created-By: NetBeans IDE
    Specified-By: MLBrowserJN.jarContent
    Main-Class: MedLEEBrowser
    If you have any ideas I'd appreciate it.

    Class-Path: xerces/xerces.jar xml-apis/xml-apis.jar xalan\xalan.jar bin\ jdom\jdom.jarWhy are you using two different file separators? (/ and \) Try using the same one throughout.
    Main-Class: MedLEEBrowserHave you correctly specified the full class name for the main class, or is the MedLEEBrowser class in the default package (i.e. no package at all)?
    And finally, is there at least one blank line at the end of your manifest file? For some reason, this is part of the Manifest file specification (although I've never understood why)

  • Could not find main class - Java virtual machine launcher error

    Hi,
    I tried executing the following cmd, below is the following error:
    <<command i executed>>
    C:\Program Files\Java\jre1.5.0_09\bin>java -classpath "C:\Program Files\Java\jre1.5.0_09\lib\javaws.jar" com.sun.javaws.Main https://<IPddr>:8443/sample.jnlp
    <<Error obtained>>
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/deploy/securi
    ty/DeployAuthenticator
    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)
    Can you pls let me know how it can be resolved?
    Thanks in advance
    -NGS

    tried executing the following cmd, below is the following error:
    <<command i executed>>
    C:\Program Files\Java\jre1.5.0_09\bin>java -classpath "C:\Program Files\Java\jre1.5.0_09\lib\javaws.jar" com.sun.javaws.Main https://<IPddr>:8443/sample.jnlp
    Can you pls let me know how it can be resolved?Umm.. I am not sure, but I will start with
    a question. Why not do it this way?C:\Program Files\Java\jre1.5.0_09\bin>javaws https://<IPddr>:8443/sample.jnlp

  • 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

  • Can not find Main Class - Can't Run Application

    I have at this for a while and it is drivng me crazy... I have an application that I want execute in a bat file. I have checked the runtime environment by executing java and javaw, both which give option on error messages. I have set the classpath to point too the class subdirectory. Here it is.., Every time I execute the bath file or execute the javaw command, I get the "Can not find main class" message.
    I am using XP ...
    Help please...
    Thanks for all your help.

    when you set the classpath I presume you mean that your running java or javaw as:
    javaw.exe -cp %classpath%;.;c:\library\myfiles com.mycomp.myapp.MainClassIf your using a jar then you must specify the jar in the class path.
    Don't presume it will find the jar. Other than that, you will have
    to provide more details.

  • Java Virtual Machine "Could not find main method"  what do i do?

    Hi I'm very new to java and for my class we are to make an applet and make a class. I figured out how to do it but the Java Virtual Machine gives me an error when I go to run the applet."Could not find the main method. Program Will exit!" . I am using Jbuilder8 personal to compile the code. Using j2sdk1.4.0_03. Could someone tell me how to fix this? Or what I'm doing wrong?
    Here is my code.
    package assignment5;
      Program: Program 5.2
      Author: Will W.
      Date: 02/20/03
      Description: Create a student class that holds the
      student name, student ID, phone and number of units
      completed. Create methods and a applet to input data
      Dispay the student name, student ID, phone, units
      completed in a text area.
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Assignment5Applet extends Applet implements ActionListener
         //Create Components
         //TextFields
         TextField txtName = new TextField(25);
         TextField txtId  = new TextField(15);
         TextField txtPhone = new TextField(15);
         TextField txtUnits = new TextField(4);
         //TextArea
         TextArea txaList = new TextArea(20,40);
         //Button
         Button btnAdd = new Button("Go");
         //Labels mostly debugging purposes.
         Label lblOutput = new Label();
         Label lblNumberProcessed = new Label();
         Label lblError = new Label();
         public void init()
              //Create the interface for the applet
              Panel pnlLayout = new Panel(new GridLayout(5, 2));
              pnlLayout.add(new Label("Name:"));
              pnlLayout.add(txtName);
              pnlLayout.add(new Label("Student Id:"));
              pnlLayout.add(txtId);
              pnlLayout.add(new Label("Phone #:"));
              pnlLayout.add(txtPhone);
              pnlLayout.add(new Label("Num Units:"));
              pnlLayout.add(txtUnits);
              add(pnlLayout);
              add(btnAdd);
              add(txaList);
              txtName.requestFocus();
              btnAdd.addActionListener(this);
              txtName.addActionListener(this);
              txtId.addActionListener(this);
              txtPhone.addActionListener(this);
              txtUnits.addActionListener(this);
         public void actionPerformed(ActionEvent evt)
                    //Variables to hold the data in the textboxes
              String strName;
              String strId;
              String strPhone;
              String strUnits;
              try
                   //Get the data
                   strName = txtName.getText();
                   strId = txtId.getText();
                   strPhone = txtPhone.getText();
                   strUnits = txtUnits.getText();
                            //Instantiate a student object
                            Student aStudent = new Student(strName, strId, strPhone, strUnits);
                            //Use get student to get the output
                         txaList.append("Output:" + aStudent.getStudent());
                   lblOutput.setText("");
              catch(NumberFormatException e)
                   lblOutput.setText("Error");
    }The my student class
    package assignment5;
      * Program: Student.java
      * Author: Will W.
      * Date: 02/20/03
      * Descrip:
      * Student Class for Assignment5Applet.java
      * Contains one constructor and 5 other methods
      * for the class
    public class Student
            //Class Variables
            private String  strName;
            private String strId;
            private String strPhone;
            private String strUnits;
            private String strOutput;
            //Constructor
            public Student(String strNewName, String strNewId, String strNewPhone, String strNewUnits)
              setName(strNewName);
              setId(strNewId);
              setPhone(strNewPhone);
              setUnits(strNewUnits);
            //Methods
            public void setName(String strNewName)
                    //Assign new value to private variable
                    strName = strNewName;
            public void setId(String strNewId)
                    strId = strNewId;
            public void setPhone(String strNewPhone)
                    strPhone = strNewPhone;
            public void setUnits(String strNewUnits)
                    strUnits = strNewUnits;
            public String getStudent()
                    //Put the output together
                    strOutput = strName + "\n" + strId + "\n" + strPhone + "\n" + strUnits;
                    return strOutput;
    }Everythings seems to compile correctly without errors it's just when I execute to the running program that the Java Virtual Machine throws me that error saying it can't find the main method.

    Java Virtual Machine "Could not find main method" what do i do?
    Ok Ok OK I got the solution for you ,this is what you do you put your hands inbetweenj you leggs and run around in a circle can scream me nuts me nuts me nuts are on fire,then come back and tell use if the problem is solved or not
    Good luck hehehehe:P

Maybe you are looking for

  • How to add new fields in the EBP front end..

    Hi All, Can any one let me know the process of how to add new fileds in the shopping cart creation screens by using the "Tag Browser" option in the Object navigator. Best Regards, Mahesh. J

  • Monitor Turning Off

    My brand new iMac monitor keeps turning off, the computer is on, just the monitor keeps shutting off.

  • How to use the FM named 'CP_EX_PLAN_READ_INTERVAL'

    Hi sirs, Can u please suggest that how can I use FM 'CP_EX_PLAN_READ_INTERVAL' for retriving the relavent data from PLKO and PLPO. I need the example of using this FM. Thanks in advance, Dinesh

  • 3GS update from 3.0.1 to 4.0.1

    I have a 3GS that I have been using with the original software version 3.0.1 that was installed on the phone when I purchased it. I have never once updated it to a later version, because everything was working perfect. I thought that I might like to

  • 816 installer error under linux 7.1

    Hi, i tried to install oracle 816 under linux 7.1 . During the time of linking makefile. The following error occur : Error in invoking target install of makefile /oraHome/network/lib/ins_net_client.mk I have already added the 6.2 backward compatable