Recall that Mac OS X is a melding of two worlds. Hard core UNIX programmers can pop open a Terminal window and write their Java code using vi and compile and run it from the command line. There is, however, the more traditional Mac audience that interacts with their computer through a friendly UI that follows Apple Human Interface guidelines. Nevertheless, how do I upgrade my Java compiler? I'm running Mac OSX 10.7.5 and my Java version is below: java version '1.6.065' Java(TM) SE Runtime Environment (build 1.6.065-b14-4) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode).
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.Java Compiler Machine Language
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.
- Advertisement
- Java2Script v.1.0Java2Script(J2S) provides an Eclipse Java to JavaScriptcompiler plugin and a JavaScript version of Eclipse SWT besides common utilities like java.lang.* and java.util.*. SWT-based RCP can be converted into RIA by using ...
- Pyjamas Web Widget Set v.0.8alpha1Pyjamas is a python to Javascriptcompiler, Widget set, Framework and Toolkit for Application development that runs on Web browsers. The developer need not know anything about AJAX: all the AJAX tricks, for all major browsers, are entirely taken care ...
- Stunnix JavaScript Obfuscator and Encoder v.3.9Stunnix JavaScript Obfuscator is very advanced professional obfuscator for .js/.html/.asp/.php/.wsc/.wsh files, with support for encoding and ensuring licensing condititions, with advanced GUI with Project Manager and ActiveX symbols extraction tool.
- DhtmlxTree - JavaScript Tree Menu v.1.2Cross-browser JavaScript Tree Menu with XML support, dynamical loading and rich API. The tree has built-in checkboxes, context menu, drag-&-drop and customizable items. There are CF and JSP tags for dhtmlxTree, as well as ASP.NET custom control.
- Active DHTML Drop Down JavaScript Menu v.4.5The DHTML Drop Down JavaScript Menu is cross browser and highly customizable. You will be quickly adding a powerful menu navigation aid to web sites, help systems, documentation, intranets and much more.
- Cursor Trail JavascriptCursor Trail Javascript is a powerful and functional tool that renders a trailing cursor whenever the user moves his ...
- Custom JavaScript error boxCustom JavaScript error box is a small yet powerful script that will detect any JavaScript errorsDon't you just hate the default, intrusive JavaScript error message box that pops up when the browser runs into a scripting error? Why not replace it ...
- DG Javascript FilterDG Javascript Filter is known as a professional and effective JAvaScript snippet that was written for the MooTools library filters in real-time list or table ...
- Javascript Scientific CalculatorJavascript Scientific Calculator is a professional and useful tool which allows you to introduce a complete calculator into any of your web pages. The script is very easy to customize. The calculator appearance (colors, dimensions, additional ...
Free Java Code Compiler
- JavaScript Quiz MachineJavaScript Quiz Machine offers an effective which helps visitors test their knowledge of a subject related to your site.Major Features:Automatically calculate a letter gradeList references for wrong answers and only allows one attempt for each ...
- Temperature Converter JavascriptTemperature Converter Javascript offers users a professional script that instantly coverts between the major temperature units Fahrenheit, Celsius, and Kelvin. It can be easily adapted to convert between others types of units. The script is ...
- Treeview - JavaScript Tree Menu v.4.3A compact, fast, reusable script that lets you enhance your site with an outliner that looks and feels exactly like Windows Explorer. Download the JavaScript/DHTML applet for free and configure it with the online visual builder. Features: - ...
- Helma Server-side JavaScript Web Application Framework for Mac OS v.1.7Helma is written in Java and employs JavaScript for its server-side scripting environment, removing the need for compilation cycles and reducing development costs while giving you instant access to leverage the whole wealth of Java libraries out ...
- MindFusion.Diagramming for JavaScript v.2.5.1JsDiagram is a flow diagramming JavaScript / HTML 5 Canvas library for web applications. It helps you create and present flowcharts, workflow and process diagrams, organizational and relationship charts, network drawings, graphs and trees.
- JavaScript Framework Shield UI v.1.7.34The JavaScript Framework by Shield UI offers various JavaScript/HTML5 components for streamlined development. Each individual control in the ever-expanding product offering boasts excellent performance and high-level of customization.
- JavaScript Pop-up box - free script v.1.0Adding the FREE JavaScript dialog box on your site will help you interact with your visitors and collect their details. The popup form emerges a few seconds after the page is loaded. Users have to submit it to access the full content of your page.
- JavaScript Diagram v.3.3.3JsDiagram is a flow diagramming JavaScript / HTML 5 Canvas library for web applications. It helps you create and present flowcharts, workflow and process diagrams, organizational and relationship charts, network drawings, graphs and trees.
- Javascript Game Engine v.1.2This is a free game engine developed for programming browser based games. It uses the Javascript language and CSS to dress up the page. They run pretty reliably together. Use this engine to create your own game. This project is intended for ...
- Editable javascript SelectBoxThis JavaScript the Code, allows to use SelectBox , simultaneously, is possibility to edit or insert a new option if the necessary element is not present in the ...
- FREE - Anti Right Click - Javascript v.1..0A very simple and powerfull Anti Right Clic javascript !!!! This script avoid the right clic of your ...
- MindFusion.Diagramming for JavaScript JsDiagram is a flow diagramming JavaScript / HTML 5 Canvas
- JavaScript Diagram JsDiagram is a flow diagramming JavaScript / HTML 5 Canvas
- Stunnix JavaScript Obfuscator and Encoder Stunnix JavaScript Obfuscator is very advanced
- DScripted Toolkit for JavaScript DScripted is a JavaScript toolkit geared towards
- FREE - Anti Right Click - Javascript A very simple and powerfull Anti Right Clic javascript
- JaCC 4 WRL - The Java compiler for WRL This project aims to provide a Java-Bytecode compiler for
- Experience JavaScript Library Experience is a set of non-traditional GUI gadgets written
- JavaScript Framework Shield UI The JavaScript Framework by Shield UI offers various
- Editable javascript SelectBox This JavaScript the Code, allows to use SelectBox ,
- DhtmlxTree - JavaScript Tree Menu Cross-browser JavaScript Tree Menu with XML support,