Compile and run java in cmd

Compile and run java in cmd

Learn Latest Tutorials

Splunk tutorial

SPSS tutorial

Swagger tutorial

T-SQL tutorial

Tumblr tutorial

React tutorial

Regex tutorial

Reinforcement learning tutorial

R Programming tutorial

RxJS tutorial

React Native tutorial

Python Design Patterns

Python Pillow tutorial

Python Turtle tutorial

Keras tutorial

Preparation

Aptitude

Logical Reasoning

Verbal Ability

Company Interview Questions

Artificial Intelligence

AWS Tutorial

Selenium tutorial

Cloud Computing

Hadoop tutorial

ReactJS Tutorial

Data Science Tutorial

Angular 7 Tutorial

Blockchain Tutorial

Git Tutorial

Machine Learning Tutorial

DevOps Tutorial

B.Tech / MCA

DBMS tutorial

Data Structures tutorial

DAA tutorial

Operating System

Computer Network tutorial

Compiler Design tutorial

Computer Organization and Architecture

Discrete Mathematics Tutorial

Ethical Hacking

Computer Graphics Tutorial

Software Engineering

html tutorial

Cyber Security tutorial

Automata Tutorial

C Language tutorial

C++ tutorial

Java tutorial

.Net Framework tutorial

Python tutorial

List of Programs

Control Systems tutorial

Data Mining Tutorial

Data Warehouse Tutorial

Javatpoint Services

JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.

  • Website Designing
  • Website Development
  • Java Development
  • PHP Development
  • WordPress
  • Graphic Designing
  • Logo
  • Digital Marketing
  • On Page and Off Page SEO
  • PPC
  • Content Development
  • Corporate Training
  • Classroom and Online Training
  • Data Entry

Training For College Campus

JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week

Like/Subscribe us for latest updates or newsletter RSS Feed Subscribe to Get Email Alerts Facebook Page Twitter Page YouTube Blog Page

Источник

How to Compile & Run Java Program Using Command Prompt

This article was co-authored by Yaffet Meshesha. Yaffet Meshesha is a Computer Specialist and the Founder of Techy, a full-service computer pickup, repair, and delivery service. With over eight years of experience, Yaffet specializes in computer repairs and technical support. Techy has been featured on TechCrunch and Time.

This article has been viewed 953,047 times.

While many programming environments will allow you to compile and run a program within the environment, you can also compile and run using Command Prompt. Both Windows and Mac have their own versions of Command Prompt, although it is technically called Terminal on the Mac OS. The process is essentially identical for Windows and Mac.

Compiling and Running

Image titled Compile & Run Java Program Using Command Prompt Step 1

  • To ensure that your file is saved as a .java file, be sure to write .java after the file name, and select All Files from the dropdown extension menu.
  • Make note of where you saved the file on your system.
  • If you are unsure of how to write a program in Java, check out our tutorial on how to program in Java. For the purposes of learning how to compile and run a program, though, you can use any sort of Java program.

Image titled Compile & Run Java Program Using Command Prompt Step 2

  • Windows: Press ⇱ Home , then type cmd. Press ↵ Enter to open the Command Prompt.
  • Mac: In Finder, press the Go tab, select Applications, select Utilities, then select Terminal.

Image titled Compile & Run Java Program Using Command Prompt Step 3

  • If not, you may need to install the Java Development Kit from their website. It is free and can be found at this link: http://www.oracle.com/technetwork/java/javase/downloads/index.html.

Image titled Compile & Run Java Program Using Command Prompt Step 4

  • For example, if you were operating in C:\Users\Bob\Project and wanted to get to C:\Users\Bob\Project\TitanProject , enter in cd TitanProject and press ↵ Enter .
  • You can see a list of what is in your current directory by typing dir and pressing ↵ Enter .

Image titled Compile & Run Java Program Using Command Prompt Step 5

  • If you have any errors in your program, or if there is difficultly compiling, the command prompt will notify you.
  • Check out our article about how to fix compiler errors in Java for more help.

Image titled Compile & Run Java Program Using Command Prompt Step 6

  • After pressing ↵ Enter , your program should run. If you receive an error, or if your program fails to run in any way, refer to the troubleshooting method.

Troubleshooting

Image titled Compile & Run Java Program Using Command Prompt Step 7

Оцените статью