Forums

Topic: How to compile a java program using a command prompt?

Posts 1 to 1 of 1

emilia777

Compiling and running a java program using a command prompt is a common practice for beginners. We do not need eclipse or any other IDE to compile a java program.
Java can be used to create small programs called applets. These applets are embedded into a web page and executed on the client computer. The program is compiled by a Java compiler such as javac. The Java compiler compiles the Java source code of the program into Java byte code, which can be executed on any computer with a suitable Java Runtime Environment (JRE) installed.

How to compile a java program using a command prompt?

Create your source file as usual with your editor of choice, or use a wizard within an integrated development environment (IDE).

2. Save the file on your hard drive in any location that is convenient for your project.

3. Open the command prompt window. You can do this by typing cmd in the search box on Windows XP and Windows 7 or by pressing [Ctrl]+[alt]+[delete] and clicking "Command Prompt" on Windows 8 and 10.

4. Navigate to the directory where your source file is located by entering the cd (change directory) command followed by the path to your file and then pressing [Enter].

5. Type javac followed by the path to your source file and then press [Enter]. For example, if I wanted to compile myfile.java in my home directory, I would type javac.

The above example compiles all java files present in the current directory and creates a .class file in the same directory from where we are running the command prompt. That's all for now, happy coding!!

https://www.regainsoftware.com/ost-to-pst-converter.html

  • Page 1 of 1

Sorry, this topic has been locked.