Already own Minecraft? Download it again for Windows, Mac and Linux. Download server software for Java and Bedrock and play with your friends. C: 'C: Program Files Java jdk1.8.0 bin javac' MyClass.java. It is useful to set the PATH variable permanently so it will persist after rebooting. To set the PATH variable permanently, add the full path of the jdk1.8.0 bin directory to the PATH variable. Typically, this full path looks something like C: Program Files Java jdk1.8.0 bin.
Java and the Windows Command Prompt
Update macbook pro hardware.
This page is obsolete.
This document instructs you on how to use the Windows Command Prompt with Java. These instructions are specialized to Windows 7, but aresimilar for Windows XP and Windows Vista.
Java |
You will use the Java compiler javac to compile your Java programs andthe Java interpreter java to run them.You should skip the first step if Java is already installed on your machine.
- Download and install the latest version ofthe Java Platform, Standard Edition Development Kit (Java SE 6 Update 27).Note the installation directory for later—probablysomething like C:Program FilesJavajdk1.6.0_27bin.
- 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. Control Panel -> System and Security -> Programs -> Advanced -> Environment Variables -> PATH-->
Control Panel -> System and Maintenance -> System -> Advanced System Settings -> Advanced -> Environment 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 FilesJavajdk1.6.0_27bin;to the beginning of the PATH variable.
- Click OK three times.
Command-line interface |
You will type commands in an application called the Command Prompt.
- Launch the command prompt viaAll Programs -> Accessories -> Command Prompt.(If you already had a command prompt window open, close itand launch a new one.)You should see the command prompt; it will look something like:
- To check that you have the right version of Java installed,type the text in boldface below. You should see something similar to the information printed below.(It's important that you see the number 1.6 or 1.5for the Java version number, but the rest is not critical.)Then type:
- Since you will be using the Command Prompt frequently,we recommend customizing the default settings.Right-click the title bar of an open Command Prompt window,select Properties and then:
- Window Size to 80 x 25. -->
- Set Layout -> Screen Buffer Size to 80 x 500.
- Select Options -> Edit Options -> QuickEdit Mode.
- Select Options -> Edit Options -> Insert Mode. Start in to 'C:introcs' or whichever directory you'd like to start in when launching the Command Prompt.-->
- Since you will be using the Command Prompt frequently,we recommend customizing the default settings.Right-click the title bar of an open Command Prompt window,select Properties and then:
Compile the Program |
You will use the javac command to convert your Java program into a form more amenable for execution on a computer.
Download Java Command Line Mac
- From the Command Prompt, navigate to the directory containingyour .java files, say C:introcshello, by typing the cd command below.
- Assuming the file, say HelloWorld.java,is in the current working directory, type thejavac command in boldface below to compile it.If everything went well, you should see no error messages.
Execute the Program |
You will use the java command to execute your program.
- From the Command Prompt, type the java command below.If all goes well, you should see the output ofthe program - Hello, World.
Input and Output |
Install Java Mac Command Line
If your program gets stuck in an infinite loop, typeCtrl-c to break out.

If you are entering input from the keyboard, you can signifyto your program that there is no more data by typingCtrl-z for EOF (end of file).On some DOS systems the first line of output sent to the screen after you enter EOF will be rendered invisible by DOS. This is not a problem with your code, but rather a problem with DOS. To help you debug your program, we recommend including an extra System.out.println(); statement before what you really want to print out. If anyone knows of a better fix, please let us know!
Troubleshooting |
Here are a few suggestions that might help correct any installationwoes you are experiencing. If you need assistance, don't hesitateto contact a staff member.
When I type, 'java -version' I get an error.Check that you edited your PATH environment variable as indicated.A missing ; or an added % is enough to screw things up.Close and re-open a command prompt.Type path at the command prompt and look for an entry that includesC:Program FilesJavajdk1.6.0_27bin;.Check that the version number 1.6.0_27matches the one you installed—Oracle updates Java periodically and youmight have a more recent version.If this doesn't fix the problem, check if you have any old versions of Javaon your system. If so, un-install them and re-install Java.
2015 macbook pro price. The command 'java -version' works, but not 'javac -version'. Any thoughts?It's likely a path issue. Try the suggestions from the previousquestion. Also check that you installed the JDK properly by checkingthat the folder C:Program FilesJavajdk1.6.0_27bin exists.
How can I check the values of my PATH variable?Type the following at the command prompt.
The PATH variable should begin withC:Program FilesJavajdk1.6.0_27bin;Be sure to open the command prompt after you have edited the PATH environment variable.You may also need to reboot for the environment variable change to take effect.Run Java From Command Line Windows
I can compile with javac, but I get the error message'Exception in thread 'main' java.lang.NoClassDefFoundError: HelloWorld'when I try to execute it with java.First, be sure that HelloWorld.class is now in the current directory.Be sure to type java HelloWorld without a trailing .classor .java.Check that the command 'java -version' works.Now try to execute with 'java -cp . HelloWorld'.If this works, you need to edit your classpath.(iTunes has a proclivity for changing the classpath,so if you recently upgraded iTunes, this is likelythe source of the problem.)
Where can I learn more about the Windows command line?Here is a short tutorial on the Windows command prompt.Microsoft maintains a completecommand line reference.
How do I change my directory to the H: drive from the Windows Command Prompt?Type H: at the command prompt. Then cd to the appropriate directory.
