đŸ•ˇī¸ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 103 (from laksa023)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

â„šī¸ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
3 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.geeksforgeeks.org/java/command-line-arguments-in-java/
Last Crawled2026-04-10 00:10:55 (3 days ago)
First Indexed2025-06-13 01:16:41 (10 months ago)
HTTP Status Code200
Meta TitleCommand Line Arguments in Java - GeeksforGeeks
Meta DescriptionYour All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more., Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Meta Canonicalnull
Boilerpipe Text
Last Updated : 24 Mar, 2026 Java command-line argument   is an argument, i.e., passed at the time of running the Java program. Command-line arguments passed from the console can be received by the Java program and used as input. Example: java Geeks Hello World Note: Here, the words Hello and World are the command-line arguments. JVM will collect these words and will pass these arguments to the main method as an array of strings called args. The JVM passes these arguments to the program inside args[0] and args[1]. Example : In this example, we are going to print a simple argument in the command line. // Java Program to Illustrate First Argument class GFG { public static void main ( String [] args ) { // Printing the first argument System . out . println ( args [ 0 ] ); } } Output: Output of first argument Explanation : Running java GFG GeeksForGeeks prints GeeksForGeeks because the argument is passed to main(String[] args). If no arguments are given (e.g., java GFG), it throws ArrayIndexOutOfBoundsException since args is empty. Why Use Command Line Arguments? It is used because it allows us to provide input at runtime without modifying the whole program. It helps to run programs automatically by giving them the needed information from outside. Working of Command-Line Arguments Command-line arguments in Java are space-separated values passed to the main(String[] args) method. JVM wraps them into the args[] array, where each value is stored as a string (e.g., args[0], args[1], etc.). The number of arguments can be checked using args.length. Example : Display Command-Line Arguments Passed to a Java Program To compile and run a Java program in the command prompt, follow the steps written below. Save the program as Hello.java Open the command prompt window and compile the program- javac Hello.java After a successful compilation of the program, run the following command by writing the arguments- java Hello For example - java Hello Geeks at GeeksforGeeks Press Enter and you will get the desired output. class Hello { // Main driver method public static void main ( String [] args ) { // Checking if length of args array is // greater than 0 if ( args . length > 0 ) { // Print statements System . out . println ( "The command line" + " arguments are:" ); // Iterating the args array // using for each loop for ( String val : args ) System . out . println ( val ); } else System . out . println ( "No command line " + "arguments found." ); } } Output: Command Line Arguments in Java Visit Course Suggested Quiz 3 Questions Why are command-line arguments useful in Java? A They speed up compilation B They remove the need for a main method C They allow providing input at runtime D They convert programs into scripts How can you check the number of command-line arguments passed to a Java program? A args.size() B args.count() C args.length D args.getLength() Where does the JVM store command-line arguments before passing them to the program? A In a HashMap B In an integer array C In the args[] array of Strings D In a file Quiz Completed Successfully Your Score : 0 / 3 Accuracy : 0% Login to View Explanation 1 /3 Comment Article Tags: Explore Java Basics OOP & Interfaces Collections Exception Handling Java Advanced Practice Java
Markdown
[![geeksforgeeks](https://media.geeksforgeeks.org/gfg-gg-logo.svg)](https://www.geeksforgeeks.org/) ![search icon](https://media.geeksforgeeks.org/auth-dashboard-uploads/Property=Light---Default.svg) - Sign In - [Courses]() - [Tutorials]() - [Interview Prep]() - [Java Tutorial](https://www.geeksforgeeks.org/java/java/) - [Advanced Java](https://www.geeksforgeeks.org/advance-java/advanced-java/) - [Interview Questions](https://www.geeksforgeeks.org/java/java-interview-questions/) - [Exercises](https://www.geeksforgeeks.org/java/java-exercises/) - [Examples](https://www.geeksforgeeks.org/java/java-programming-examples/) - [Quizzes](https://www.geeksforgeeks.org/java/java-quiz/) - [Projects](https://www.geeksforgeeks.org/blogs/java-projects/) - [Cheatsheet](https://www.geeksforgeeks.org/java/java-cheat-sheet/) - [DSA in Java](https://www.geeksforgeeks.org/dsa/dsa-in-java/) - [Java Collection](https://www.geeksforgeeks.org/java/java-collection-tutorial/) # Command Line Arguments in Java Last Updated : 24 Mar, 2026 Java command-line argumentis an argument, i.e., passed at the time of running the Java program. Command-line arguments passed from the console can be received by the Java program and used as input. Example: > java Geeks Hello World ****Note:**** Here, the words Hello and World are the command-line arguments.JVM will collect these words and will pass these arguments to the main method as an array of strings called args. The JVM passes these arguments to the program inside args\[0\] and args\[1\]. ****Example****: In this example, we are going to print a simple argument in the command line. Java `` ****Output:**** ![Output 1](https://media.geeksforgeeks.org/wp-content/uploads/20241227111123375183/cmd.png) Output of first argument ****Explanation****: - Running java GFG GeeksForGeeks prints GeeksForGeeks because the argument is passed to main(String\[\] args). - If no arguments are given (e.g., java GFG), it throws ArrayIndexOutOfBoundsException since args is empty. ### Why Use Command Line Arguments? - It is used because it allows us to provide input at runtime without modifying the whole program. - It helps to run programs automatically by giving them the needed information from outside. ## Working of Command-Line Arguments - Command-line arguments in Java are space-separated values passed to the main(String\[\] args) method. - JVM wraps them into the args\[\] array, where each value is stored as a string (e.g., args\[0\], args\[1\], etc.). - The number of arguments can be checked using args.length. ### ****Example****: Display Command-Line Arguments Passed to a Java Program To compile and run a Java program in the command prompt, follow the steps written below. - Save the program as Hello.java - Open the command prompt window and compile the program- javac Hello.java - After a successful compilation of the program, run the following command by writing the arguments- java Hello - For example - java Hello Geeks at GeeksforGeeks - Press Enter and you will get the desired output. Java `` ****Output:**** ![Output 2](https://media.geeksforgeeks.org/wp-content/cdn-uploads/output-1.png) Command Line Arguments in Java [Visit Course![course link icon](https://media.geeksforgeeks.org/auth-dashboard-uploads/Vector11.svg)](https://www.geeksforgeeks.org/courses/java-online-course-complete-beginner-to-advanced) Suggested Quiz ![reset](https://media.geeksforgeeks.org/auth-dashboard-uploads/Reset-icon---Light.svg) 3 Questions Why are command-line arguments useful in Java? - A They speed up compilation - B They remove the need for a main method - C They allow providing input at runtime - D They convert programs into scripts How can you check the number of command-line arguments passed to a Java program? - A args.size() - B args.count() - C args.length - D args.getLength() Where does the JVM store command-line arguments before passing them to the program? - A In a HashMap - B In an integer array - C In the args\[\] array of Strings - D In a file ![success](https://media.geeksforgeeks.org/auth-dashboard-uploads/sucess-img.png) Quiz Completed Successfully Your Score :0/3 Accuracy :0% Login to View Explanation **1**/3 \< Previous Next \> Comment [T](https://www.geeksforgeeks.org/user/Twinkle%20Tyagi/) twinkle tyagi 193 Article Tags: Article Tags: [Java](https://www.geeksforgeeks.org/category/programming-language/java/) [java-basics](https://www.geeksforgeeks.org/tag/java-basics/) ### Explore [![GeeksforGeeks](https://media.geeksforgeeks.org/auth-dashboard-uploads/gfgFooterLogo.png)](https://www.geeksforgeeks.org/) ![location](https://media.geeksforgeeks.org/img-practice/Location-1685004904.svg) Corporate & Communications Address: A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305) ![location](https://media.geeksforgeeks.org/img-practice/Location-1685004904.svg) Registered Address: K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305 [![GFG App on Play Store](https://media.geeksforgeeks.org/auth-dashboard-uploads/googleplay-%281%29.png)](https://geeksforgeeksapp.page.link/gfg-app)[![GFG App on App Store](https://media.geeksforgeeks.org/auth-dashboard-uploads/appstore-%281%29.png)](https://geeksforgeeksapp.page.link/gfg-app) - Company - [About Us](https://www.geeksforgeeks.org/about/) - [Legal](https://www.geeksforgeeks.org/legal/) - [Privacy Policy](https://www.geeksforgeeks.org/legal/privacy-policy/) - [Contact Us](https://www.geeksforgeeks.org/about/contact-us/) - [Advertise with us](https://www.geeksforgeeks.org/advertise-with-us/) - [GFG Corporate Solution](https://www.geeksforgeeks.org/gfg-corporate-solution/) - [Campus Training Program](https://www.geeksforgeeks.org/campus-training-program/) - Explore - [POTD](https://www.geeksforgeeks.org/problem-of-the-day) - [Job-A-Thon](https://practice.geeksforgeeks.org/events/rec/job-a-thon/) - [Blogs](https://www.geeksforgeeks.org/category/blogs/?type=recent) - [Nation Skill Up](https://www.geeksforgeeks.org/nation-skill-up/) - Tutorials - [Programming Languages](https://www.geeksforgeeks.org/computer-science-fundamentals/programming-language-tutorials/) - [DSA](https://www.geeksforgeeks.org/dsa/dsa-tutorial-learn-data-structures-and-algorithms/) - [Web Technology](https://www.geeksforgeeks.org/web-tech/web-technology/) - [AI, ML & Data Science](https://www.geeksforgeeks.org/machine-learning/ai-ml-and-data-science-tutorial-learn-ai-ml-and-data-science/) - [DevOps](https://www.geeksforgeeks.org/devops/devops-tutorial/) - [CS Core Subjects](https://www.geeksforgeeks.org/gate/gate-exam-tutorial/) - [Interview Preparation](https://www.geeksforgeeks.org/aptitude/interview-corner/) - [Software and Tools](https://www.geeksforgeeks.org/websites-apps/software-and-tools-a-to-z-list/) - Courses - [ML and Data Science](https://www.geeksforgeeks.org/courses/category/machine-learning-data-science) - [DSA and Placements](https://www.geeksforgeeks.org/courses/category/dsa-placements) - [Web Development](https://www.geeksforgeeks.org/courses/category/development-testing) - [Programming Languages](https://www.geeksforgeeks.org/courses/category/programming-languages) - [DevOps & Cloud](https://www.geeksforgeeks.org/courses/category/cloud-devops) - [GATE](https://www.geeksforgeeks.org/courses/category/gate) - [Trending Technologies](https://www.geeksforgeeks.org/courses/category/trending-technologies/) - Videos - [DSA](https://www.geeksforgeeks.org/videos/category/sde-sheet/) - [Python](https://www.geeksforgeeks.org/videos/category/python/) - [Java](https://www.geeksforgeeks.org/videos/category/java-w6y5f4/) - [C++](https://www.geeksforgeeks.org/videos/category/c/) - [Web Development](https://www.geeksforgeeks.org/videos/category/web-development/) - [Data Science](https://www.geeksforgeeks.org/videos/category/data-science/) - [CS Subjects](https://www.geeksforgeeks.org/videos/category/cs-subjects/) - Preparation Corner - [Interview Corner](https://www.geeksforgeeks.org/interview-prep/interview-corner/) - [Aptitude](https://www.geeksforgeeks.org/aptitude/aptitude-questions-and-answers/) - [Puzzles](https://www.geeksforgeeks.org/aptitude/puzzles/) - [GfG 160](https://www.geeksforgeeks.org/courses/gfg-160-series) - [System Design](https://www.geeksforgeeks.org/system-design/system-design-tutorial/) [@GeeksforGeeks, Sanchhaya Education Private Limited](https://www.geeksforgeeks.org/), [All rights reserved](https://www.geeksforgeeks.org/copyright-information/) ![]()
Readable Markdown
Last Updated : 24 Mar, 2026 Java command-line argumentis an argument, i.e., passed at the time of running the Java program. Command-line arguments passed from the console can be received by the Java program and used as input. Example: > java Geeks Hello World ****Note:**** Here, the words Hello and World are the command-line arguments.JVM will collect these words and will pass these arguments to the main method as an array of strings called args. The JVM passes these arguments to the program inside args\[0\] and args\[1\]. ****Example****: In this example, we are going to print a simple argument in the command line. `` ****Output:**** ![Output 1](https://media.geeksforgeeks.org/wp-content/uploads/20241227111123375183/cmd.png) Output of first argument ****Explanation****: - Running java GFG GeeksForGeeks prints GeeksForGeeks because the argument is passed to main(String\[\] args). - If no arguments are given (e.g., java GFG), it throws ArrayIndexOutOfBoundsException since args is empty. ### Why Use Command Line Arguments? - It is used because it allows us to provide input at runtime without modifying the whole program. - It helps to run programs automatically by giving them the needed information from outside. ## Working of Command-Line Arguments - Command-line arguments in Java are space-separated values passed to the main(String\[\] args) method. - JVM wraps them into the args\[\] array, where each value is stored as a string (e.g., args\[0\], args\[1\], etc.). - The number of arguments can be checked using args.length. ### ****Example****: Display Command-Line Arguments Passed to a Java Program To compile and run a Java program in the command prompt, follow the steps written below. - Save the program as Hello.java - Open the command prompt window and compile the program- javac Hello.java - After a successful compilation of the program, run the following command by writing the arguments- java Hello - For example - java Hello Geeks at GeeksforGeeks - Press Enter and you will get the desired output. `` ****Output:**** ![Output 2](https://media.geeksforgeeks.org/wp-content/cdn-uploads/output-1.png) Command Line Arguments in Java [Visit Course![course link icon](https://media.geeksforgeeks.org/auth-dashboard-uploads/Vector11.svg)](https://www.geeksforgeeks.org/courses/java-online-course-complete-beginner-to-advanced) Suggested Quiz 3 Questions Why are command-line arguments useful in Java? - A They speed up compilation - B They remove the need for a main method - C They allow providing input at runtime - D They convert programs into scripts How can you check the number of command-line arguments passed to a Java program? - A args.size() - B args.count() - C args.length - D args.getLength() Where does the JVM store command-line arguments before passing them to the program? - A In a HashMap - B In an integer array - C In the args\[\] array of Strings - D In a file ![success](https://media.geeksforgeeks.org/auth-dashboard-uploads/sucess-img.png) Quiz Completed Successfully Your Score :0/3 Accuracy :0% Login to View Explanation **1**/3 Comment Article Tags: ### Explore
Shard103 (laksa)
Root Hash12046344915360636903
Unparsed URLorg,geeksforgeeks!www,/java/command-line-arguments-in-java/ s443