UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How can I execute a Java program?

Asked by Last Modified  

5 Answers

Learn Java

Follow 5
Answer

Please enter your answer

Technical Lead and Architect - BigData,Databricks, SnowFlake,Pyspark,Azure Cloud ,Confluent Kafka

Through command-line 1.compile the code using javac filename.java 2. Finally run the code using java filename here filename is classname. If u use eclipse then right click the java code n select run as java application .
Comments

Java source code is compiled into bytecode when we use the javac compiler. The bytecode gets saved on the disk with the file extension .class . When the program is to be run, the bytecode is converted, using the just-in-time (JIT) compiler. The result is machine code which is then fed to the memory and...
read more
Java source code is compiled into bytecode when we use the javac compiler. The bytecode gets saved on the disk with the file extension .class . When the program is to be run, the bytecode is converted, using the just-in-time (JIT) compiler. The result is machine code which is then fed to the memory and is executed. read less
Comments

Running a Java Program from Command Prompt ------------------------------ Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text: public class HelloWorld { public static void main(String args) { System.out.println("Hello,...
read more
Running a Java Program from Command Prompt ------------------------------ Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java. Run Command Prompt (found under All Programs/Accessories in the Start menu). Type C:\> cd \mywork This makes C:\mywork the current directory. C:\mywork> dir This displays the directory contents. You should see HelloWorld.java among the files. C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.8.0_51\bin (use the JDK folder for the version installed on your system). This tells the system where to find JDK programs. C:\mywork> javac HelloWorld.java This runs javac.exe, the compiler. You should see nothing but the next system prompt... C:\mywork> dir javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files. C:\mywork> java HelloWorld This runs the Java interpreter. You should see the program output: Hello, World! If the system cannot find javac, check the set path command. read less
Comments

Tutor

At Dos prompt , write following commands Javac filename E.g. Javac x.java To run program after compilation Write following code Java filename E.g. Java x
Comments

Download and install the latest version of the Java Platform, Standard Edition Development Kit (Java SE 6 Update 27). Note the installation directory for later—probably something like C:\Program Files\Java\jdk1.6.0_27\bin. To make sure that Windows can find the Java compiler and interpreter: Select Start...
read more
Download and install the latest version of the Java Platform, Standard Edition Development Kit (Java SE 6 Update 27). Note the installation directory for later—probably something like C:\Program Files\Java\jdk1.6.0_27\bin. To make sure that Windows can find the Java compiler and interpreter: Select Start -> Computer -> System Properties -> Advanced system settings -> Environment Variables -> System variables -> PATH. [ In Vista, select Start -> My Computer -> Properties -> Advanced -> Environment Variables -> System variables -> PATH. ] [ In Windows XP, Select Start -> Control Panel -> System -> Advanced -> Environment Variables -> System variables -> PATH. ] Prepend C:\Program Files\Java\jdk1.6.0_27\bin; to the beginning of the PATH variable. Click OK three times. Then Compile the Program From the Command Prompt, navigate to the directory containing your .java files, say C:\introcs\hello, by typing the cd command below. C:\Users\username>cd c:\introcs\hello C:\introcs\hello\> Assuming the file, say HelloWorld.java, is in the current working directory, type the javac command in boldface below to compile it. C:\introcs\hello\>javac HelloWorld.java C:\introcs\hello\> Execute the Program From the Command Prompt, type the java command below. C:\introcs\hello\>java HelloWorld Hello, World If all goes well, you should see the output of the program - Hello, World. read less
Comments

View 3 more Answers

Related Questions

Is it possible to instantiate the abstract class?
Use anonymous class. Example: For an abstract class AbstrClass. AbstrClass ac = new AbstrClass() { public void m1() { // code...
Reshma
Do I need to import java.lang package any time? Why?
No, you don't need to import it at any time. As this is part of java.lang package is a part of \jdk1.6.0_11{this is the location f your jdk installation directory}\jre\lib\rt.jar and this rt.jar (called...
Anitha
Please tell me what Object Oriented Programming and Object Based Programming with reallife example..what is the difference between them.?
Hi Ritesh, In order to be a true object oriented programming language, following 4 need to be present… 1) Abstraction - Hiding the implementation details from the user, only the functionality will...
Ritesh
What is the general syllabus covered in core Java training from any institution?
you can check the syallbus on http://felix-its.com/java-training-pune/
Shiv Kohli
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Observer Pattern in Java.
As I was going through the different source code files of the Java Util package, I found the implementation of the Observer Pattern ( see the Gang of Four books for more information on this pattern) in...

CONDITIONAL STATEMENT - IF ELSE
1. IF condition only if is true conditon is required. if(condition){//statements} 2. IF-ELSE condition 1. to check whether the condition will be true or false.syntax of if-else2. only 1 conditionif(condition){//statements}else{//statements} 3....

How To Setup development Environment Of Java?
After installation of JAVA, we need to setup 2 environment variables. First one is JAVA_HOME and second is Path. Below steps to set up Java environment to compile & execute Java programs from command...

What Is Applet & Its Life Cycle?
What is Applet & its life cycle?Applet is a Java programme that can be embedded into HTML page.Java Applet runs on the java enables web browsers such as Mozilla & Internet Explorer.Applets are...
I

ICreative Solution

0 0
0

Java Hash Map internal implementation
1.Hash Map internal implementation: In hash map it will create an array of table (to store the {Key,Value} pair) which is of type java.util.HashMap.EntryThe Entry object contains {hash, key, next, value}...
R

Recommended Articles

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more