Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: my run program does not work

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default my run program does not work

    so i made a compile and run program in notepad so that i can compile and run my java programs but for some reason my run program doesn't work. whenever i run it, it says: "Could not find the main class: hello. program will exit.".

    this is what i have coded in note pad for run.bat:

    @echo off
    echo Please wait, running......
    java hello
    pause

    i have jdk 1.6.0_16 installed and i'm pretty sure that the classpath and path are correct so i'm not sure whats going on.

    CLASSPATH: C:\Program Files\Java\jdk1.6.0_16\bin
    PATH: C:\Program Files\Java\jdk1.6.0_16\bin

    yes, the class has the same name as the file.

    thanks


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: my run program does not work

    mmm... command line java

    I'd get an IDE like Eclipse or Netbeans. That will fix all your pathing problems (well, not all, but pretty close)

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: my run program does not work

    Hi rman27bn,
    With error: "Could not find the main class", I think that your "hello" class don't have a main function.
    Such as:
    class hello
    {
    //----------------
    public static void main(String args[])
    {
    }
    //----------------
    }

    Another comment to you that if you want to use command line to compile java program, you should make a file .bat as:
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16\bin
    REM call when compile ----
    %JAVE_HOME%\java.exe filename

    You can learn batch script language to more.

    Good luck,
    Tien

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: my run program does not work

    Quote Originally Posted by tien1504 View Post
    Hi rman27bn,
    With error: "Could not find the main class", I think that your "hello" class don't have a main function.
    Such as:
    class hello
    {
    //----------------
    public static void main(String args[])
    {
    }
    //----------------
    }

    Another comment to you that if you want to use command line to compile java program, you should make a file .bat as:
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16\bin
    REM call when compile ----
    %JAVE_HOME%\java.exe filename

    You can learn batch script language to more.

    Good luck,
    Tien
    He has already set his PATH environment variable, so he has no need to fiddle around with JAVA_HOME etc etc.

    I'd guess that what you said first i correct, of course the class must also be public,

    @OP
    perhaps share some code with us? so we can see what you have?

    Chris

Similar Threads

  1. Long term project work from home developer
    By internext in forum Paid Java Projects
    Replies: 17
    Last Post: May 2nd, 2012, 07:51 PM
  2. [SOLVED] Can't get JFreeChart to work
    By igniteflow in forum Java SE APIs
    Replies: 2
    Last Post: February 15th, 2011, 02:19 AM
  3. Why won't this while loop work?
    By trueblue in forum Loops & Control Statements
    Replies: 2
    Last Post: July 17th, 2009, 09:10 AM