Use Notepad and Command Prompt for Java Programming: Hello, in this instructable, I will show you how to create, and execute a program that you created in java using notepad. You will need to open some things:-Notepad-Command Prompt. Running Java Control Panel through command line in Windows Vista. Open command prompt and type javaws -version. Java control panel will open. Graham says: June 22, 2012 at 12:10 pm. Plus the PAY for assistance is a real shame of a scam on folks. Next laptop is a MAC and no JAVA. When I see companies purposefully make it costly.
Java and the Mac OS X Terminal
This page is obsolete.
This document instructs you on how to use the Mac OS X Terminal with Java.
You will use the Java compiler javac to compile your Java programs andthe Java interpreter java to run them.To verify that Apple's implementation of Java 2 Standard Edition (Java SE 6) isalready installed:
- Run Software Update.
- Run Applications/Utilities/Java/Java Preferencesand verify that the Java SE 6 - 64-bit entry is checked andfirst in the list; if not, drag to change the preferred order.
You will type commands in an application called the Terminal.
- Open a terminal window. You can find this underGo -> Applications -> Utilities. Drag the Terminal to your dock sinceyou will be using it frequently.
- You should now have a Terminal window somewhere on the screen.It will have a prompt that looks something like:
- To check that you are running the right version of Java, typethe commands in boldface below. You should see something similar to the information printed below. The importantpart is that it says 1.6 or 1.5 (and not 1.4).
Then type
- Since you will be using the Terminal frequently, you may want tocustomize the default window settings (e.g., Monaco 13pt font with antialiasing).
- To check that you are running the right version of Java, typethe commands in boldface below. You should see something similar to the information printed below. The importantpart is that it says 1.6 or 1.5 (and not 1.4).
You will use the javac command to convert your Java program into a form moreamenable for execution on a computer.
- From the Terminal, navigate to the directory containing your .javafiles, say ~wayne/introcs/hello, by typing the cd commandbelow.
- Assuming the file, say HelloWorld.java is in the currentworking directory, type the javac command below to compile it.
If everything went well, you should see no error messages.
- Assuming the file, say HelloWorld.java is in the currentworking directory, type the javac command below to compile it.
You will use the java command to execute your program.
- From the Terminal, type the java command below.If all goes well, you should see the output of the program -Hello, World.
Input and Output |
If your program gets stuck in an infinite loop, type Ctrl-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-d for EOF (end of file).You should type this character on its own line.
When I try to run java I get: Exception in thread 'main' java.lang.NoClassDefFoundError.First, be sure that HelloWorld.class is in the current directory.Be sure to type java HelloWorld without a trailing .classor .java.If this was not your problem, it's possiblethat your CLASSPATH was set by some other program so that it no longerincludes the current working directory.Try running your program with the command line
If this works, your classpath is set incorrectly.I get the error 'class file has wrong version 50.0, should be 49.0' when I compilefrom the Terminal. What does this mean?It's probably because DrJava is configured to use Java 6.0 and and your Terminal is configured to use Java 5.0.To change the default version of Java in your Terminal, launchJava Preferencest. Drag the Java SE 6 - 64-bit entryto appear first.
How do I get the menu to display at the topof the screen instead of at the top of the frame?Execute with java -Dapple.laf.useScreenMenuBar=true
Where can I learn more about the command line?Here is a short tutorial on thecommand-line.
How can I find which version of Java is installed without running an applet in Windows or Mac?
This article applies to:- Platform(s): Mac OS X, Windows 10, Windows 7, Windows 8, Windows Vista, Windows XP, macOS
- Java version(s): 7.0, 8.0
- in the Java Control Panel (Windows and Mac)
- in terminal window command line (Mac)
Use any of these options if you are having trouble running applets to confirm that you have a specific Java version.
Java Version under Windows Start Menu - Java 7 Update 40 (7u40) and later versions
Starting with Java 7 Update 40, you can find the Java version through the Windows Start menu.- Launch the Windows Start menu
- Click on Programs
- Find the Java program listing
- Click About Java to see the Java version
Java Version in the Java Control Panel - Windows and Mac
The Java version can be found in the Java Control Panel.
- Find the Java Control Panel on Windows
Find the Java Control Panel on Mac - Under the General tab in the Java Control Panel, the version is available through the About section. A dialog appears (after clicking About) showing the Java version.
Java Version in Windows Programs
The latest version(s) of Java on your system will be listed as Java 8 with an associated Update number (eg. Java 8 Update 111). Older versions may be listed as Java(TM), Java Runtime Environment, Java SE, J2SE or Java 2.
Windows 10
- Click the Start button
- Scroll through the applications and programs listed until you see the Java folder
- Click on the Java folder, then About Java to see the Java version
Windows 8
- Right-click on the screen at bottom-left corner and choose the Control Panel from the pop-up menu.
- When the Control Panel appears, select Programs
- Click Programs and Features
- The installed Java version(s) are listed.
Windows 7 and Vista
- Click Start
- Select Control Panel
- Select Programs
- Click Programs and Features
- The installed Java version(s) are listed.
Windows XP
- Click Start
- Select Control Panel
- Click the Add/Remove Programs control panel icon
- The Add/Remove control panel displays a list of software on your system, including any Java versions that are on your computer.
Using the Command-line to find Java Versions - Mac
The Java Runtime (JRE) that you download from java.com or oracle.com contains a plugin to run Java content from your browser. In order to use the command line tools, you will need to download the Java Development Kit (JDK). The JRE and JDK are separate and can coexist on your system. Only one JRE can be installed on Mac. There can be multiple JDKs installed on a system, as many as you wish.
JRE Version Command Line on Mac
Type the following in a Terminal window:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
Determining the Default Version of the JDK on Mac
When launching a Java application through the command line, the system uses the default JDK. It is possible for the version of the JRE to be different than the version of the JDK.
You can determine which version of the JDK is the default by typing
java -version
in a Terminal window. If the installed version is 7u55, you will see a string that includes the text 1.7.0_55
. For example:java -version
java version '1.7.0_55'
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)