answersLogoWhite

0


Best Answer

You execute it the same way you would on any other OS. As long as you have the Java Runtime Environment installed and the "java" executable is in your path, from the command line you would simply run: java -cp /path/to/file/here com.some.class.to.run.Here

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

On the command line, type "java" followed by the filename of the compiled class, e.g.:

java myClass.class

On the command line, type "java" followed by the filename of the compiled class, e.g.:

java myClass.class

On the command line, type "java" followed by the filename of the compiled class, e.g.:

java myClass.class

On the command line, type "java" followed by the filename of the compiled class, e.g.:

java myClass.class

This answer is:
User Avatar

User Avatar

Wiki User

14y ago
  1. Install the JRE - Java Runtime Environment
  2. Set the PATH and CLASSPATH environment variables
  3. Compile the file using the javac command
  4. Run the class using the java command
This answer is:
User Avatar

User Avatar

Wiki User

14y ago

"java" is the keyword/command used to execute Java Programs

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

On the command line, type "java" followed by the filename of the compiled class, e.g.:

java myClass.class

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

java -jar nameofjarfile.jar

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Command use on how to run a java program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you compile and execute Java program in which we find the highest of any five numbers?

In the same way as you would compile and execute any other Java program. Compile: use the "javac" command. Or use the built-in "compile" command in your favorite IDE. Execute: Use the "java" command. Or use the built-in "run" command in your favorite IDE.


What JDK command is used to run a java application in byteCodeclass?

To run a Java program, you use the following form: java ClassFileName ClassFileName is the name of the .class file that you wish to execute. However, you do not type the .class extension.


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)


Once you have downloaded and installed the Java SE JDK Update 26 for Windows how do you open it-It shows up as a folder and it doesn't open java program when clicked on?

The Java Development Kit is not a program designed to be opened up and used, rather it is a folder of command line tools used to compile java programs. If you want to use a program to create/edit java code that automates the compiling process check out NetBeans or Eclipse. Also, if you are trying to open an already compiled java program with it, read the documentation that came with the java application on how to run it.

Related questions

How do you compile and execute Java program in which we find the highest of any five numbers?

In the same way as you would compile and execute any other Java program. Compile: use the "javac" command. Or use the built-in "compile" command in your favorite IDE. Execute: Use the "java" command. Or use the built-in "run" command in your favorite IDE.


What JDK command is used to run a java application in byteCodeclass?

To run a Java program, you use the following form: java ClassFileName ClassFileName is the name of the .class file that you wish to execute. However, you do not type the .class extension.


What is the command to compile and execute a factorial program in java?

Compile: either use the "javac" command or - more conveniently - look for the "compile" command in some of the menus of your IDE. Run: after compiling, use the "java" command or - more conveniently - look for a "run" command in your IDE. The exact commands in the IDE will vary, depending will vary depending on the chosen IDE.


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


How do you initiate the main method in java?

By calling the class that contains it. To test it in your IDE, use the "run" command on this file. To run it independently (once it is compiled), if your class is called MyClass, run the following command from a command window:java MyClassWhen you run a class, the Java Virtual Machine will automatically look for a method called main(), and run it.


How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)


Once you have downloaded and installed the Java SE JDK Update 26 for Windows how do you open it-It shows up as a folder and it doesn't open java program when clicked on?

The Java Development Kit is not a program designed to be opened up and used, rather it is a folder of command line tools used to compile java programs. If you want to use a program to create/edit java code that automates the compiling process check out NetBeans or Eclipse. Also, if you are trying to open an already compiled java program with it, read the documentation that came with the java application on how to run it.


What is classpath and path in java?

if you are using the IDE then there is no need to set class path, ant you are using Command prompt to run the java program then you need to set the class path where the class (which is going to be used in your program) is actually located,use the following command:set calsspath=%classpath%;actual_path_of the class;we cancall more than two class by using this command by using separator (,)


How do you compile in java?

You either use the command-line program javac, for example: javac MyClass (assuming your program is called MyClass.java), or - more conveniently - look for the menu command to compile, in your favorite IDE.


What statement do you use to make a group of classes available to a program?

You would use the import command. For example:import java.lang;To do this with custom classes, it requires two things:These classes are grouped inside a package, so the java program can use themThese packages are included inside the program, just like the java jdk


Can a Java program use one or more command line arguments?

Command line arguments in Java are, as with most programming languages, a way to give information to a program at the point of invoking (starting to run) that program. The information is given in the form of a text string. Command line arguments are accessible in a Java program as an array of String objects passed into the program's "main" method. Unlike some programming languages (such as C/C++), where the command used to invoke the program is passed into the first array location (index 0) and the arguments subsequently, in Java the first argument occupies index 0. Command line arguments are a useful way of gathering information from the user when it is likely will know the information at the start of the program. For example, a Java application might copy a file from myFile.txt to myNewFile.txt by running the command "java CopyUtil myFile.txt myNewFile.txt". It is useful to allow such information to be passed in via command line arguments to make the program more scriptable: in other words, more conducive to scripted invocation, through a Desktop shortcut, through a batch file, through a shell script, etc.


How do i open a java file in Microsoft visual studio using the command prompt i know you would type notepad helloworld period java to open a java program in notepad but how do i do it for MVS?

You don't want to use Microsoft Visual Studio to edit/run Java programs... http://www.eclipse.org/downloads/ Use the Eclipse IDE instead... Visual Studio's only for C/C++ language programs.