How To Run Java Program

Table of contents:

How To Run Java Program
How To Run Java Program

Video: How To Run Java Program

Video: How To Run Java Program
Video: how to compile and execute java program 2024, April
Anonim

An application written in the java language is a jar archive or a set of *.java and *.class files, if the component programs are not compiled into an executable jar archive. To run such applications, you need to install the Java Runtime Environment.

How to run java program
How to run java program

Necessary

  • - the Internet;
  • - Java Runtime Environment program.

Instructions

Step 1

Go to the official java developers site at https://java.sun.com/javaee/sdk/ and download the latest java machine. Install the program on the hard drive of your computer. Specify the operating system with the path to the installed files of the java machine - to do this, add the path to the installation location of the program to the path parameter of the environment variables (the Advanced tab in the computer properties window).

Step 2

Run the command line through the main menu or by using the cmd command entered in the Run box. Go to the command line in the directory of the java program that you want to run. Enter the command: java -cp [filename].jar [name of the main class of the program] Press Enter - the file will be executed.

Step 3

If you need to compile java files, enter javac [main file name].java followed by java -cp [filename]. For information about the options for running java files from the command line, enter the java -help statement and press Enter. A complete list of possible commands and their options will appear on the screen. Enter all commands accurately, as erroneous combinations can harm the entire operating system of a personal computer.

Step 4

If you need to run mini-games written in java for mobile devices on your computer, download the MidpX program. This application allows you to run jar files without unnecessary complications. Once this software is installed, right-click on one of the jar files and select Properties. Next, a window will appear in which click on the "Change" button and select the appropriate program to open this type of files, that is, the MidpX utility.

Recommended: