• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Test Case Examples
  • Interview Questions
  • Interview Questions Asked
  • Java
  • Java Program
  • Selenium
  • Selenium Programs
  • Manual Testing
  • Difference
  • Tools
  • SQL
  • Contact Us
  • Search
SoftwareTestingo » Java » Java Tutorial » How to Compile Java in Command Prompt Or in a Terminal

How to Compile Java in Command Prompt Or in a Terminal

Last Updated on: April 9, 2019 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • How to Run the JAVA program in Command prompt
  • Open Command Prompt in Folder
  • How to Compile a java program in Command Prompt:

How to Compile a Java Program in Command Prompt in a Terminal: In this JAVA tutorial, we are going to see how to write a simple JAVA program, compile and run the JAVA program in command prompt.

public class SeleniumJavaProgram {
   public static void main(String[] args) 
   {
      System.out.println("This Is My First Program");
   }
}

if we run this program then the output should come as: This is my first program in JAVA selenium series

Read Also: Core Java Interview Questions

How to Run the JAVA program in Command prompt

  • Before writing the program there is some prerequisite are there like you have to install java in your system and set JAVA_Home Variable on your system.
  • You Can copy and paste in an editor like notepad, TextEdit or you can write in any IDE like Eclipse, NetBeans or IntelliJ IDEA like editors which are available online for free download.
  • After writing the program save that program as “SeleniumJavaProgram.Java”.
  • The next step after saving the program is to compile the program. for compile, you can open the command prompt and terminal in case if you are using the Mac operating system.
  • For compile the program you can type the below command and hit enter
javac SeleniumJavaProgram.Java

Open Command Prompt in Folder

Compile In Java Command Prompt
Compile In Java Command Prompt

Note: After hit enter if you are getting any error like this “Javac’ is not recognized as an internal or external command, operable program or batch file” that means the path is not set in your system, from here you can learn how to set Java path in windows?

Check Also:  Java Programs for Testers
  • Once you set the path after that if you compile the java program then you are not getting any error and after a successful compilation, the java file is converted into a .class file which is byte code.
  • Now we can run the java program in command prompt. to run the program type the below command and hit enter.
Java SeleniumJavaProgram

How to Compile a java program in Command Prompt:

Execute Java Command Prompt
Execute Java Command Prompt
Programs: Interview Related Java Programs

Please write comments if you find anything incorrect, or you want to share more information about this topic discussed above then you can use our contact us page.

    Filed Under: Java Tutorial

    Reader Interactions

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2023 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers