Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Don't understand the error

Don't understand the error

Scheduled Pinned Locked Moved Java
helpjavacomxmltutorial
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rorilila
    wrote on last edited by
    #1

    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)

    S L 2 Replies Last reply
    0
    • R rorilila

      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)

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0
      • R rorilila

        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)

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        That usually means that the code has been stored in the wrong folder. You should have a file named Odds.class inside your folder named weekthreeassignments. Check your build settings. As far as the actual code is concerned, it does work correctly.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups