Gettiing errors when trying to run Creating Objects lesson in Netbeans | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Gettiing errors when trying to run Creating Objects lesson in Netbeans

Hello, I am getting errors in the output seen at the bottom of the screen. Can anyone help me please? My code */ package animal2; /** * * @author chris */ public class Animal2 { void bark(){ System.out.println("Woof-Woof"); } } public MyClass{ public static main void (String[] args) { Animal2 dog = new Animal2(); dog.bark(); } } My Output run: Error: Main method not found in class animal.Animal, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application C:\Users\chris\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)

23rd Nov 2016, 1:03 PM
Making A Change
Making A Change - avatar
1 Answer
0
You have the word main and void backwards. The function should look like this: public static void main(String args[]){ //code here. } I also don't know if you can have two public classes in the same file. But that might just be me. Last thing is at the beginning of your code you may have a stray closing of a multi-lined comment. By this i mean the '*/' Hope this helps!
13th Dec 2016, 3:47 AM
Gabe Maxfield
Gabe Maxfield - avatar