Firstly ->I wanted to ask that whether Assertion error is JVM or Programmer Exception?
Secondly -> When we don't write main method in our program and execute code then it gives like->
Error: Main method not found in class a.TestClass, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
So above is Error or Exception???
Assertion error is JVM or Programmer Exception?
Moderator: admin
-
- Posts: 26
- Joined: Sun Jul 23, 2017 2:13 am
- Contact:
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Assertion error is JVM or Programmer Exception?
1. Thrown by the JVM when an assertion fails. Please read ExceptionClassSummary document given with our question bank.
2. The error message itself is quite clear. It is an Error.
2. The error message itself is quite clear. It is an Error.
If you like our products and services, please help us by posting your review here.
-
- Posts: 26
- Joined: Sun Jul 23, 2017 2:13 am
- Contact:
Re: Assertion error is JVM or Programmer Exception?
Thank you very much. Ok next time i take care about it
-
- Posts: 1
- Joined: Tue Nov 23, 2021 12:48 am
- Contact:
Re: Assertion error is JVM or Programmer Exception?
In Java, each application must have the main method. The main method is the entry point of every java program. The java program searches for the main method while running. This error occurred when the main method is not available. The reason that the compiler don't complain about the public is because it doesn't care about the main method. It doesn't take difference for it if a main exists or not. It's the JVM which need a start point public and static to launch your application.
So you should make your main method as public:
public static void main(String[] args)
The JVM is programmed to look for a specific signature for the main method before executing the program. It finds this signature by looking for a specific series of bytes in the bytecode. That signature only results from compiling a method that is - public static void main. If any of the three modifiers (public, static and void) are omitted the bytecode code will look different and the JVM will not be able to find your main method.
So you should make your main method as public:
public static void main(String[] args)
The JVM is programmed to look for a specific signature for the main method before executing the program. It finds this signature by looking for a specific series of bytes in the bytecode. That signature only results from compiling a method that is - public static void main. If any of the three modifiers (public, static and void) are omitted the bytecode code will look different and the JVM will not be able to find your main method.
Who is online
Users browsing this forum: No registered users and 75 guests