- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Enable Assertions from the command line in Java
By default, assertions are disabled in Java. In order to enable them we use the following command −
java -ea Example (or) java -enableassertions Example
Here, Example is the name of the Java file.
Let us see an example for generation of an assertion error by the JVM −
Example
public class Example { public static void main(String[] args) { int age = 14; assert age >= 18 : "Cannot Vote"; System.out.println("The voter's age is " + age); } }
Output
The voter's age is 14
- Related Articles
- Command line arguments in Java
- Java command line arguments
- Command Line arguments in Java programming
- Assertions in Java
- Explain Java command line arguments.
- Connecting to MySQL database from the command line?
- Connect to MySQL database from command line
- How to run TestNG from command line?
- How to repair MySQL tables from the command line?
- How to run Python functions from command line?
- How to call Python module from command line?
- How to upgrade MySQL server from command line?
- Generating a SHA-256 hash from the Linux command line
- How to find the version of Java using command line?
- How can we return to windows command shell from MySQL command line tool?

Advertisements