how to run a java program

Asked by Last Modified  

20 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Training Centre

Two ways you can run a Java Program. 1- Through cmd prompt, 2- Through Eclipse. 1- cmd prompt (Write your program and save the file with .java extension. Now open your cmd prompt and give the java file location. (a)- Now type the command "javac yourfilename.java" and click on ENTER button. This will...
read more
Two ways you can run a Java Program. 1- Through cmd prompt, 2- Through Eclipse. 1- cmd prompt (Write your program and save the file with .java extension. Now open your cmd prompt and give the java file location. (a)- Now type the command "javac yourfilename.java" and click on ENTER button. This will compile the program and checks whether you have syntax error. (b)- Now type the next command "java className" and click on ENTER button. Now the program will run. 2- If you are running in Eclipse. Just click on the RUN button at the topmenu. read less
Comments

Java "name of your class which contains your main method" Example : java sample Note : you need to compile before you run your program (javac filename.java)
Comments

G Chandra babu

If you java beginer just user Notepad or EditPlus editor to write a java program just follow the bellow steps to compile and run a java program steps: 1. develop/ write java code that contain main method 2.save the program as "anyfilename.java"....Note*: you should save with extension of...
read more
If you java beginer just user Notepad or EditPlus editor to write a java program just follow the bellow steps to compile and run a java program steps: 1. develop/ write java code that contain main method 2.save the program as "anyfilename.java"....Note*: you should save with extension of file ".java" 3.open command prompt and change location of developed java program area 4.here just complie the java program using javacompile syntax for compiling: c:\>javac anyfilename.java (press enter) java compliler is successfully compiles the program 5.Now run the compiled program using "java interpretter program" sysntax for running a java program using "java interpretter program" c:\>java anyfilename (press enter) 6.now output of the program is shown on your console. Hope this article help you understand how to compile and run a java program. if you like the article please like read less
Comments

Software Developer, Expertise in Java/J2ee Technology.

In command prompt, go to java program file location : a.) Compile via command :- javac FileName.java b.) Run via command :- java ClassName Note : FileName is name of java file, which can contain one or more classes. ClassName is name of one of the class in file ie class which...
read more
In command prompt, go to java program file location : a.) Compile via command :- javac FileName.java b.) Run via command :- java ClassName Note : FileName is name of java file, which can contain one or more classes. ClassName is name of one of the class in file ie class which is needed to run ( usually class containing main() method ). read less
Comments

Computer Science Tutor

go to command prompt then write the following-- For compilation: javac filename.java then press enter For run: java classname then press enter
Comments

Hello Prem Kumar :-). Here is a complete detail of how to run Java Program with other information which is as follows: Java and the Windows Command Prompt ****************************************** This document instructs you on how to use the Windows Command Prompt with Java. These instructions...
read more
Hello Prem Kumar :-). Here is a complete detail of how to run Java Program with other information which is as follows: Java and the Windows Command Prompt ****************************************** This document instructs you on how to use the Windows Command Prompt with Java. These instructions are specialized to Windows 7, but are similar for Windows... more» read less
Comments

Java/J2EE, B.E./B.Tech/MCA SubjectsTraining

Simpler way is to use Eclipse editor you don't need to compile it.
Comments

under the installation folder for Java(inside Program Files) there are java binaries under the folder named bin, this folder has all the required binaries to execute, compile,create rmi stubs and skeletons etc commands.So firstly make sure that you modify the PATH variable of your computer to point to...
read more
under the installation folder for Java(inside Program Files) there are java binaries under the folder named bin, this folder has all the required binaries to execute, compile,create rmi stubs and skeletons etc commands.So firstly make sure that you modify the PATH variable of your computer to point to this bin folder, then open the command prompt take it to the folder location of your java program and run javac command followed by your file name with dot java extension...this will generate the necc class files and then run the java command followed by the name of your file without the dot java extension.The same thing can be done easily in Eclipse IDE the only difference is Eclipse does the javac and java command on your behalf. read less
Comments

Teacher

Either run it through cmd or use an IDE like Eclipse
Comments

Software Developer and Trainer with 10 years of experience

You can run a java program either using any IDE(Integrated Development Environment) like Eclipse or Netbeans or simply through the Command Prompt. As you seems to be beginner, I discuss only about running it in command prompt. First, type your java program in any plain text editor like notepad and...
read more
You can run a java program either using any IDE(Integrated Development Environment) like Eclipse or Netbeans or simply through the Command Prompt. As you seems to be beginner, I discuss only about running it in command prompt. First, type your java program in any plain text editor like notepad and save it in a folder. While saving, name the file by the class name that contains the main function in the program. Save it with .java extension. Before running the program, you have to install Java Development Kit (jdk). Also you need to set the java environment variable. Next, you have to compile your program. To do so, use the "javac" command. Type javac filename.java to compile. If you encounter any errors, clear it and recompile again. Once the compilation is successful, a filename.class file will be created in the same folder where you have stored your .java file. Now your program is ready to run. To run your program use "java" command. Type java classname (same as filename). Now your program will be executed. Hope this will help you . . . Wish you to execute successfully . . . read less
Comments

View 18 more Answers

Related Questions

Can finally block be used without try block?
A finally clause ensures that the finally block is executed after the try block and any catch block that might be executed, no matter how control leaves the try block or catch block.
Sarala
What is JavaBean?
A JavaBean is just a standard All properties private (use getters/setters) A public no-argument constructor Implements Serializable. That's it. It's just a convention. Lots of libraries...
Ankit
0 0
6
1.What is Model Driven Interceptors is used for? 2.what is the purpose of using Action support??
Using ActionSupport class, we can implement Custom validation which validates at the server-side. We can write server side validation logic in validate() method.
Monisha
What is the difference between core java and advanced java?
core java is base for Advance java. Means whatever you want to develop it needs core java with features in Adv java
Anurag
0 0
8

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

Ask a Question

Related Lessons

Difference Between Checked And Un-Checked Exception
1. Exception is an abnormal condition in the program, if raises program terminates abnormally. 2. Exception always occurs at runtime only, there is no chance of exception at compile time. 3. Syntactical...


Differences Between HashMap vs HashSet In Java.
HashSet HashMap HashSet implements Set interface. HashMap implements Map interface. HashSet stores the data as objects. HashMap stores the data as key-value pairs. HashSet...

Software Testing
Software testing is a process of executing a program or application with the intent of finding the software bugs. It can also be stated as the process of validating and verifying that a software program...

JAVA - Object Cloning
JAVA - Object Cloning Is the way of creating the same copy of object without calling the class constructor. It means we can make any class object multiple times without calling its default constructor....

Recommended Articles

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 >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

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 >

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 >

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