Results 1 to 8 of 8
  1. #1
    ideaman is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Default newbie question: Error: Could not find or load main class Java Result: 1

    Hello all,

    I am trying to learn java and I have this error several times:

    Error: Could not find or load main class chinese1.Chinese1
    Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)

    As you can guess the project name is chinese1.
    But the same problem happened in several other projects, it starts ok then I make a change in the code and I get this error.
    Even If I delete or make comments on the new code it doesn't help!!
    In the chinese1 project i even make a comment of all the code and still has this error!!



    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package chinese1;

    //import java.io.FileInputStream;
    //import javazoom.jl.player.Player;

    /**
    *
    * @author Tiksuv
    */
    public class Chinese1 {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here
    // Chinese ChForm = new Chinese();
    // ChForm.setVisible(true);
    //
    // try {
    // FileInputStream file= new FileInputStream("C:\\ChineseWords\\tu3.mp3");
    // Player playmp3= new Player(file);
    // playmp3.play();
    //
    // } catch (Exception e){
    //
    // }

    }
    }


    I don't get it.
    I work with Netbeans 7.0.1
    I want to understand what I am doing wrong in general because it happened at other projects and also specifically for this project that I am just starting and want to continue without starting it over.

    Thanks in advance,
    Daniel

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    You have a class Chinese1 in a package chinese1 so the full name of the class is chinese1.Chinese1; and that's how you're supposed to run it:

    Java Code:
    java chinese1.Chinese1
    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    ideaman is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    Hi,

    I don't "run" anything, I just press the > button (or F6) in netbeans.
    I've also opened the command prompt to run what you told me and I still get the same error.

    Daniel

  4. #4
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    5

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    What does F6 do? I thought F11 was clean and build in Netbeans?

  5. #5
    ideaman is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    F11 is Build Main Project
    F6 is Run Main Project

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    Quote Originally Posted by ozzyman View Post
    What does F6 do?
    Run the main class in your project ;-)

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    Quote Originally Posted by ideaman View Post
    F11 is Build Main Project
    F6 is Run Main Project
    And what class are you trying to run?

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  8. #8
    ideaman is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Default Re: newbie question: Error: Could not find or load main class Java Result: 1

    Happy New Year!!
    I am trying to run the Chinese1 class
    What I did so far is this:
    I've created a new project Chinese1
    Netbeans created the Chinese1.java file I posted here
    I also created another class for the GUI and opened it from the main without problems
    I then started to do what i saw here: Play mp3 using java.mp4 - YouTube
    to add mp3 playing abbility to the program
    then I've got the error I posted, even though i remarked the new code it didn't help to get the code running again
    The problem is that I get this kind of error on the simplest of programs sometimes
    I am trying to learn java with my son and it is really annoying that small code changes in a small program gets me this error and nothing I do can fix it.
    That is why also a general question because it is not the first time I get this error.
    Is there another java development platform for Windows that can I use to develop software with GUI like Netbeans?
    I've tryed Eclipse but the GUI development it is not "built in" like in Netbeans.
    I want also to develop to Android, after I got better in java.

Similar Threads

  1. Replies: 10
    Last Post: 02-02-2012, 09:26 PM
  2. Replies: 29
    Last Post: 02-02-2012, 09:23 PM
  3. Replies: 3
    Last Post: 12-09-2011, 04:51 AM
  4. Error: Could not find or load main class Ops.java
    By Javasubbu in forum New To Java
    Replies: 4
    Last Post: 10-05-2011, 10:52 PM
  5. Error: Could not find or load main class
    By ITSlave in forum New To Java
    Replies: 4
    Last Post: 09-15-2011, 09:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •