package com.company; public class Main { int x = 5; }
//below is a separate class I have created to run my code in:
package com.company; import java.sql.SQLOutput; class Second { public static void main(String[] args) { Main myObj = new Main(); System.out.println(myObj.x); } }
This is the error message I get when I run my second class
Error: Main method not found in class com.company.Main, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
Advertisement
Answer
I have just found out – I was running my class Second and I needed to run class Main as that is where my main() method is located! Cheers anyway