Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Error: Could not find or load main class

2882122Feb 10 2015 — edited Feb 11 2015

Hello everyone!

I have decided to finally start learning Java and am currently, and slowly, making my way through the tutorials. I am only on chapter 2 in the class section. While reading I came uponJava Tutorials Sample Code and wanted to try and compile it in netbeans. This is the code that it contained:

class BicycleDemo {

    public static void main(String[] args) {

        // Create two different

        // Bicycle objects

        Bicycle bike1 = new Bicycle();

        Bicycle bike2 = new Bicycle();

        // Invoke methods on

        // those objects

        bike1.changeCadence(50);

        bike1.speedUp(10);

        bike1.changeGear(2);

        bike1.printStates();

        bike2.changeCadence(50);

        bike2.speedUp(10);

        bike2.changeGear(2);

        bike2.changeCadence(40);

        bike2.speedUp(10);

        bike2.changeGear(3);

        bike2.printStates();

    }

}

I did the following in order:

1) New project

2) Select Java under Categories and Java Application under Projects

3) I type BicycleDemo in the Project Name Field and click finish

4) I delete all the template code and paste the above code into the field

5) I click run and get the following error:

run:

Error: Could not find or load main class bicycledemo.BicycleDemo

Java Result: 1

BUILD SUCCESSFUL (total time: 0 seconds)

Any help would be greatly appreciated! Thanks!

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 11 2015
Added on Feb 10 2015
5 comments
2,595 views