Don't understand the error
-
Can anyone help me figure this out? I wrote the following code for my programming class. :confused: package weekthreeassignments;
/**
*
* @author fred
*/public class Odds {
public static void main(String[] args) {
int product = 1;
for (int i = 1; i <= 15; i++)
if (i % 2 == 1) {
product *= i;
}
System.out.println("Product of the odd integers from 1 to 15 is: " + product);
}
}When I run the code I get the following error and how to fix it, but if you read the "Please define" part, I did define it that way. Why am I still erroring? Error: Main method not found in class weekthreeassignments.Odds, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application C:\Users\fred\AppData\Local\NetBeans\Cache\10.0\ex ecutor-snippets\run.xml:111: The following error occurred while executing this line: C:\Users\fred\AppData\Local\NetBeans\Cache\10.0\ex ecutor-snippets\run.xml:68: Java returned: 1 BUILD FAILED (total time: 0 seconds)
-
Can anyone help me figure this out? I wrote the following code for my programming class. :confused: package weekthreeassignments;
/**
*
* @author fred
*/public class Odds {
public static void main(String[] args) {
int product = 1;
for (int i = 1; i <= 15; i++)
if (i % 2 == 1) {
product *= i;
}
System.out.println("Product of the odd integers from 1 to 15 is: " + product);
}
}When I run the code I get the following error and how to fix it, but if you read the "Please define" part, I did define it that way. Why am I still erroring? Error: Main method not found in class weekthreeassignments.Odds, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application C:\Users\fred\AppData\Local\NetBeans\Cache\10.0\ex ecutor-snippets\run.xml:111: The following error occurred while executing this line: C:\Users\fred\AppData\Local\NetBeans\Cache\10.0\ex ecutor-snippets\run.xml:68: Java returned: 1 BUILD FAILED (total time: 0 seconds)
Seems like you created a JavaFX project, which by definitions puts application code in a JavaFX specific Application class. Thus, your main class has to extend it. If you want to have the JavaFX GUI application, study a tutorial: [JavaFX Tutorial - javatpoint](https://www.javatpoint.com/javafx-tutorial) Otherwise create a normal java application project. Most IDEs call the normal java project type "Empty Project" or "Java Project".
Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...
-
Can anyone help me figure this out? I wrote the following code for my programming class. :confused: package weekthreeassignments;
/**
*
* @author fred
*/public class Odds {
public static void main(String[] args) {
int product = 1;
for (int i = 1; i <= 15; i++)
if (i % 2 == 1) {
product *= i;
}
System.out.println("Product of the odd integers from 1 to 15 is: " + product);
}
}When I run the code I get the following error and how to fix it, but if you read the "Please define" part, I did define it that way. Why am I still erroring? Error: Main method not found in class weekthreeassignments.Odds, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application C:\Users\fred\AppData\Local\NetBeans\Cache\10.0\ex ecutor-snippets\run.xml:111: The following error occurred while executing this line: C:\Users\fred\AppData\Local\NetBeans\Cache\10.0\ex ecutor-snippets\run.xml:68: Java returned: 1 BUILD FAILED (total time: 0 seconds)