Why cant java.exe or javaw find the "main" function?

I have compiled and run programs a few times without any problems. Then on my last project, the program complied fine, but when I tried to run it, I got the error with java.exe:
Exception in thread "main" java.lang.NoClassDefFoundError: myprogram
When I ran it with javaw.exe, I got the error:
Could not find the main class. Program will exit!
I have looked over my code again and again to see if I made any mistakes that I am missing, but cannot find any. I have tried reinstalling everything (I am using Java 2 Standard Edition 1.4.1 02, if it makes a difference). And I even did a simple test program and got the same error. The program is:
public class test
static void main( String args[] )
System.out.println("I found the main class");
Does anyone have any suggestions as to the cause of this error and how to fix it?

Does anyone have any suggestions as to the cause of
this error and how to fix it?try renaming your source file to be Test.java
modify content to be:public class Test {
public static void main(String[] args) {
  System.out.println("it works fine now");
}and then compile it with command javac Test.java and run whit command java Test
BTW. you said you had error:
Exception in thread "main" java.lang.NoClassDefFoundError: myprogram
that refers to problem that you're trying to execute program myprogram but your source sait its name was test.

Similar Messages

  • Could not find the main class: SearchExcel.  Program will exit.  ????

    sekic0429{uabudd_milou}[w10/rbssw/2.0] pwd
    /tmp/MyJava/jexcelapi
    sekic0429{uabudd_milou}[w10/rbssw/2.0] printenv CLASSPATH
    /tmp/MyJava/excelapi:/app/jdk/1.6.0_16/jre/lib:/app/jdk/1.6.0_16/lib
    sekic0429{uabudd_milou}[w10/rbssw/2.0] ls
    build ExcelSearch.java index.html resources SearchExcel.java~ tutorial.html
    docs ExelSearch.java~ jxl.jar SearchExcel.class src workbook.dtd
    ExcelSearch.class formatworkbook.dtd jxlrwtest.xls SearchExcel.java TestSpecification.xls
    sekic0429{uabudd_milou}[w10/rbssw/2.0] javac -extdirs . ExcelSearch.java
    sekic0429{uabudd_milou}[w10/rbssw/2.0]
    sekic0429{uabudd_milou}[w10/rbssw/2.0] java ExcelSearch
    Exception in thread "main" java.lang.NoClassDefFoundError: ExcelSearch
    Caused by: java.lang.ClassNotFoundException: ExcelSearch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: ExcelSearch. Program will exit.
    sekic0429{uabudd_milou}[w10/rbssw/2.0] cat ExcelSearch.java
    import java.io.File;
    import java.io.IOException;
    import java.util.Date;
    import jxl.*;
    import jxl.read.biff.BiffException;
    public class ExcelSearch
    public static void main(String[] args)
    try
    Workbook workbook = Workbook.getWorkbook(new File("TestSpecification.xls"));
    catch (IOException e)
    e.printStackTrace();
    catch (BiffException e)
    e.printStackTrace();
    Regards Peter, hope for answer

    r035198x wrote:
    Where is SearchExcel.class?Excellent question, though I think I spotted a problem with the cp supplied.
    Note the documentation for -cp state (in part)
    For example, if directory foo contains a.jar and b.JAR, then the class path element foo/* is expanded to a A.jar:b.JAR, except that the order of jar files is unspecified.So instead of this..
    java -cp /tmp/MyJava/excelapi:/app/jdk/1.6.0_16/jre/lib:/app/jdk/1.6.0_16/lib SearchExcel..try this..
    java -cp /tmp/MyJava/excelapi/*:/app/jdk/1.6.0_16/jre/lib:/app/jdk/1.6.0_16/lib SearchExcelNotes:
    1) Adding the JRE classes to the classpath should not be necessary, but I left the rest of the cp unaltered to highlight the one specific difference I am suggesting.
    2) When posting code, code snippets, HTML/XML or input/output, please use the code tags. The code tags help retain the indentation and formatting of the sample. To use them, select the sample text and click the CODE button.
    If that still fails, tell us more specifically where the SearchExcel class is by copy/pasting the output (within code tags) of the command..
    prompt>jar -tvf mysearchexcel.jarWhere, of course, you replace 'mysearchexcel.jar' with the actual Jar name it is supposed to be located in.
    Edit 1:
    Changed JavaDocs -> documentation.
    Edited by: AndrewThompson64 on Jan 11, 2010 7:12 PM

  • Could not find the main class: projectRFID.ProjectGUI. Program will exit.

    Hello,
    I'm quite new in Java. I have an application with GUI. When I'm using Eclipse version 3.4.0 to run the application, all it is working perfect.
    But after I generate the jar from Eclipse, using the manifest file option from there and added the ProjectGUI to it, where is the main class, and try to run from the command line I receive the next error:
    root@slax:~/workspace# java -jar rfid.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: projectRFID/ProjectGUI
    Caused by: java.lang.ClassNotFoundException: projectRFID.ProjectGUI
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: projectRFID.ProjectGUI. Program will exit.
    root@slax:~/workspace#
    I run this application on a SLAX system with jdk6 update 7.
    I tried to generate the jar file even from the command line using the manifest file option but I still receive the same error.
    I hope somebody can help me!
    Thank you!

    cojogrizli wrote:
    The structure of my project in Eclipse is src/project/files.java and in jar file is src/files.java bin/class.java Dati/ and META-INF/.That's wrong. You don't need the .java files in the jar (but you can have them, if you want, they are just not used by Java).
    And each .class file must be in a directory that reflects its package. So in your example ProjectGUI.class must be in the directory projectRFID/ inside the .jar file.

  • HT201343 My MBP is Early 2011 but dunno why cant use mirroring with apple TV, the icon cannot be found

    My MBP is Early 2011 but dunno why cant use mirroring with apple TV, the icon cannot be found. So cannot use mirroring.
    I have follow trouble shooting , they recommend to go system preference -> display , thus can find out the mirroring icon if no mean it doesnt support. But according to the web, Early 2011 MBP should be able to use, dunno why.

    Just realise I havent updated my OS to mountain lion and this is the reason why I cannot use mirroring before ^^
    Thanks all

  • Please let me know if Java.exe and Javaw.exe is embedded in Oracle.

    What versions of Java.exe or Javaw.exe is embedded in Oracle. If java executables are embedded, then please inform what versions of Oracle have Java executables embedded.

    >
    What versions of Java.exe or Javaw.exe is embedded in Oracle. If java executables are embedded, then please inform what versions of Oracle have Java executables embedded.
    >
    Oracle 11.1+ includes AND REQUIRES Java 1.5.
    Oracle 11g requires version 1.5 and you CANNOT update the version. Any attempt to do so can possibly corrupt your Oracle version and will prevent Oracle from working properly.
    Note that also means you cannot load Java source or class files into Oracle that use functionality from Java 1.6+.
    See the Java Developer's Guide
    http://docs.oracle.com/cd/E11882_01/java.112/e10588/chone.htm
    >
    Feature List of Oracle JVM
    Table 1-1 lists the features of Oracle JVM and the versions in which they were first supported.
    Table 1-1 Feature List of Oracle JVM
    Feature Supported Since Oracle JVM Release
    JDK 1.5 support
    11.1

  • Detecting launcher (java.exe vs javaw.exe)?

    I found myself wondering this morning if one could and how if one could one would detect if the launcher of a particular main(...) were java.exe or javaw.exe programatically. Or by extension could one detect if Swing interfaces were supported.
    Consider that one had an application that could be launched from a command line or could be launched as a Swing windowed application. If there was a problem during startup the launcher (or if Swing was supported at the moment) might just be a relevant question when trying to give meaning full information back to the user. Trying to display information in (for example) a JOptionPane would be useless if the current environment didn't support it, and likewise if the launcher was javaw.exe sending the output to System.out or System.err would never be visible to the user.
    Spitting out the System.properties yielded some interesting and useful information, but nothing that just screamed at me, "Use me to determine where to send the output."
    Thoughts comments or suggestions?
    Thanks in advance,
    PS.

    I thought headless was supposed to handle this?
    http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/
    When your app was run in javaw or java on Windows,
    either way your app IS allowed to open a graphical window.
    So you cannot tell which way it is.
    But if your app is run from the server, or via some nongraphical connection
    to a UNIX machine, then supposedly headless would be true.
    And you can test for that.

  • Java Access Bridge 1.1 Could not find the main class

    When I try to load Java Access Bridge 1.1 I receive the following error:
    Could not find the main class. Program will exit.
    Does anyone know why?

    you must check with the classpath
    please see that you have not repeated %classpath%
    at the end of the class path like you do in win98.
    similiarly with %path%
    in win2000 it is automatically taken care off.

  • Two java.exe processes running in the Task Manager in Windows XP

    I tried to find the best possible place to post this and after spending about 20 minutes searching for an appropriate forum starting from java.com I ended up here. So forgive me if the is a wrong place and if there?s a more appropriate place for my question, please provide a pointer to it.
    I don't know much about java and what it does but as the title says when I open the Task manager there are two java.exe processes running at the same time with about 20 000 k each.
    One of the processes is coming from:
    C:\Program Files\Alias\Maya6.5\docs\jre\bin\java.exe
    and the other from:
    C:\Program Files\Alias\Maya7.0\docs\jre\bin\java.exe
    in addition to that a jusched.exe process is also running coming from
    C:\Program Files\Java\jre1.5.0_10\bin\jusched.exe
    I rarely open the Maya 6.5 and 7 documentations but the two java.exe process are running all the time and I would like to stop them running when I don?t need them but I don?t know how.
    I can't end these processes from the Task Manager; they reappear immediately after I end them.
    Any help with this is greatly appreciated.
    Thank you

    Try to see:
    http://forums.cgsociety.org/showthread.php?t=294973
    Bye,
    leo

  • 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

  • Java.exe - Application error. The instruction at "0x504c42b8" referenced memory at "0x00000009".The memory cannot be "read".

    Our production application is experiencing the following error with increasing
    frequency.
    Windows 2000 Dialog Box:
    java.exe - Application error.
    The instruction at "0x504c42b8" referenced memory at "0x00000009".The memory cannot
    be "read".
    Click on OK to terminate program.
    Does anybody know the cause and solution to this problem?
    We're using WL 5.1.0 sp11 jvm version 1.2.2_007
    However, searching the web indicates the error message occurs with a variety of
    configurations.
    [javaError.gif]

    John Slaman wrote:
    >
    Our production application is experiencing the following error with
    increasing frequency.
    Windows 2000 Dialog Box:
    java.exe - Application error.
    The instruction at "0x504c42b8" referenced memory at "0x00000009".The
    memory cannot be "read".
    Click on OK to terminate program.
    Does anybody know the cause and solution to this problem?
    We're using WL 5.1.0 sp11 jvm version 1.2.2_007
    However, searching the web indicates the error message occurs with a
    variety of configurations.I believe this is a memory flaws problem, cannot read memory can be in 2
    ways: either the address has been allocated (reserved) by some other
    resources or the address specified is not valid (phantom lookup).
    Try to get a higher version of WLS.
    Thanks,
    Neo Gigs
    "Follow the white rabbit..."

  • Could not find the main class. & java.lang.NoClassDefFound error:

    sir / madam
    I am facing problems with j2ksdk1.4.0 beta instalation on my windows 2000 advance server.
    while installing pops up a message saying could not find the main class.
    while using java or javac it says
    Exception in thread main
    java.lang.NoClassDefFound error:
    com/sun/tools/javac/main
    even when double clicking java plugin from the control panel
    I get the Java virtual machine launcher saying could not find the main class.
    I don't have any other java sdk installed.
    And i have my environment variables (classpath, path and java_home) set correctly.
    this same j2sdk1.4.0 version is installed in the windows 98 system and it's working fine.
    Kindly do help me to solve this problem.
    eagerly awaiting for your response.
    Thanking you
    Sajeev Nair
    [email protected]

    you must check with the classpath
    please see that you have not repeated %classpath%
    at the end of the class path like you do in win98.
    similiarly with %path%
    in win2000 it is automatically taken care off.

  • Why Cant I Delete in Recents Calls the ones I want to ?

    Why Cant I Delete In Recent Calls the ones I want to ?

    Because Apple designed the iOS for it to be all or nothing. You can tell Apple you'd like to see a change here:
    http://www.apple.com/feedback/iphone.html

  • Java Virtual Machine Launcher could not find the main class - program will

    I have installed J2SE and followed all the instructions but upon restarting the PC I get a dialogue box with the messege Java Virtual Machine Launcher could not find the main class - program will exit.
    I have tried multiple times un-installing and re-intalling this but i still get the messege when i restart windows.
    Can anyone offer any suggestions as to what i may be doing wrong.
    When I do the verify installation I get the congtratulations you have the latest Java Installed.
    Help

    Something is being automatically started when the pc starts. Assuming Windows, to see what it is, learn to use the msconfig program:
    http://www.google.com/search?q=how+to+use+msconfig
    Apparently, whatever it is, it's not correctly configured.

  • "Java Virtual Machine Launcher-   could not find the main class"

    My system is working very slowly, especially during start-up.
    During the start-up, a small pop-up appears that reads:
    "Java Virtual Machine Launcher
    could not find the main class. Program will exit"
    Would this cause slow operation?
    How do I fix this?
    My system is Windows XP Professional, version 2002 SP1; Intel Pentium III Processor, 647 MHz, 128 RAM
    Thanks for whatever help you can offer.
    Lou
    My experience level is
    Beginner
    Novice
    Intermediate X
    Expert
    Guru

    That popup message indicates that some program has tried to start the Microsoft JVM. When this occurs at startup, it often means that a spyware (or worse) program is operating. Go to this Sun site for more information.
    http://java.com/en/download/help/spyware.jsp

  • I want to upload from my iphone playlist to my laptop (Windows 8) why is it so hard to find the right buttons to press????

    i want to upload from my iphone playlist to my laptop (Windows 8) why is it so hard to find the right buttons to press????

    Review these Knowledge Base articles... they may help you:
    Synchronizing media using BlackBerry Desktop Software on a Mac computer
    BlackBerry Desktop Software Mac does not display evens and albums from iPhoto 9.4.2
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for

  • Anyone using Time Capsule as a NAS? Thinking of getting one...

    Hello guys, I plan to purchase a 2TB TC because I need a NAS. I have a ATV2 which I will JB and install XBMC, an XBOX, A LG LED LM7600 with Smart TV and networking features, a mac book air and 2 iPhones. I want to be able to stream HD content (movies

  • Inserting Images in a Table

    When I insert images in a table and align them right, for example, there are still a few pixels between the edge of the table and the image on the top and right. How do I make an image go to the absolute edge of a table? Thanks, Chris

  • Re: JPEG to Movie.java

    Sir, I have started new Post.Can u now assist me Sir? I saw JMF code samples section that would convert JPEG images to .Mov files. I tried to run that code by giving 2 images as runtime parameters. But i got NullPointerException Here are the list of

  • Print pdf from WD JAVA

    Hi All I have a requirement to print PDF form from  WD without to see the PDF form i'll be glad to see your suggestions Yossi

  • Please help, i cannot purchase the full feat. It only tell that connot be completed.

    GUys help me, i already downloaded the app but i can't purchase the full feature of the garageband. It only tell that purchase cannot be completed.