This document instructs you on how to set up a Java programming environment for your Mac OS X computer. It also provides a step-by-step guide for creatingand compiling a Java program in IntelliJ and executing itfrom the command line.
Mac Pro introduced in early 2008 or later Xserve models introduced in early 2009. To find your Mac model, memory, storage space, and macOS version, choose About This Mac from the Apple menu. If your Mac isn't compatible with OS X El Capitan, the installer will let you know. Some Mac users have to install Java in OS X El Capitan, perhaps because of compatibility with a particular website or application, or because they are a Java developer. But Apple has become increasingly strict with Java, and by default it no longer installs with a clean install of OS X 10.11, and you will find that after updating a Mac, an.
You will need a Mac runningMac OS X 10.13 (High Sierra) to Mac OS X 10.15 (Catalina).
0. Install the Java Programming Environment |
The installer installs and configures a Java programming environment, includingOpenJDK 11 andIntelliJ IDEA, Community Edition 2020.1.
Warning
If you have previously used IntelliJ,run this installer only if you want a clean re-install.The installer overwrites IntelliJ IDEA CE.app andany previous IntelliJ 2020.1 settings.
1. Open a Project in IntelliJ |
You will develop your Java programs in an application called IntelliJ IDEA, Community Edition.
IntelliJ organizes Java programs into projects.In our context, each project corresponds to one programming assignment.A typical project contains Java programs, associated data files, andcourse-specific settings (such as compiler options, style rules, and textbook libraries).
[ sample project for COS 126 (Princeton) ]
[ sample project for COS 226 (Princeton) ]
[ sample project for Computer Science: Programming with a Purpose (Coursera) ]
Klocki for mac. [ sample project for Algorithms, Part I (Coursera) ]
Double click the zip file to unzip.This creates a project folder with thename of the corresponding programming assignment (such as hello
or percolation
).Delete the zip file.
Warning
The project folders contain course-specific information. Be sure to downloadthe one corresponding to your institution and course.
Warning
Do not select Create New Project;this option is intended for advanced programmers.Also, always use Open with a project folder, not an individual file.2. Create a Program in IntelliJ |
Now you are ready to write your first Java program.IntelliJ features many specialized programming toolsincluding line numbering, syntax highlighting, bracket matching, auto indenting,auto formatting, auto importing, variable renaming, and continuous code inspection.
HelloWorld.java
exactly as it appears below.(IntelliJ generates the gray boilerplate code automatically,along with the course header block comment.)If you omit even a semicolon, the program won’t work.3. Compile and Execute the Program (from IntelliJ) |
Now, it is time to execute (or run) your program.This is the exciting part, where your computer follows the instructionsspecified by your program.Before doing so, you must compile your program intoa form more amenable for execution on a computer.
If the compilation fails, a Recompile panel will open up (at bottom),highlighting the compile-time errors or warnings.Check your program carefully for typos, using the error messages as a guide.
You should see the output of the program (in white), along with a messagethat the program finished normally (with exit code 0).
Tip
Use the LIFT menu to compile and execute your program from IntelliJ.The Build and Run menus support additional options for advanced programmers.
Also be sure that the main editor window is active before using the LIFTmenu (e.g., by clicking the code you want to compile or execute).
4. Compile and Execute the Program (from the command line) |
The command line is a simple and powerful mechanism forcontrolling your programs (e.g., command-line arguments,file redirection, and piping).IntelliJ supplies an embedded terminalfor easy access to the command line.
The ~/Desktop/hello
is the current working directory, where~
is shorthand for your home directory.
javac
command.More specifically, type the text in yellow that appears on the same line as thecommand prompt.Assuming that the file HelloWorld.java
is in the current working directory,you should not see any compile-time errors or warnings.java
command:You should see the output of your program beneath the line on which you typed the command.Tip
Typically, you should compile from IntelliJ(because IntelliJ highlights the lines on which anycompile-time errors or warnings occur) and execute from the command line(because the command line makes it is easy to specify command-line argumentsand use file redirection).
5. Textbook Libraries (from the command line) |
To make our textbook libraries accessible to Java from the command line,you will use our wrapper scripts.
stdlib.jar
to draw aBarnsley fern.First download Barnsley.java.Then, use the Finder to move itto a project folder (such as hello
).Finally, to compile and execute it,type the following commands in the terminal:When you execute the program, a standard drawing window will appearand an image like this one will be generated, one point at a time:To get your command prompt back, close the standard drawing window.
algs4.jar
to simulate the motion of n disks subject to the lawsof elastic collision.First download CollidingDisks.javaThen, use the Finder to move it to a project folder (such as percolation
).Finally, to compile and execute it,type the following commands in the terminal:When you execute the program, a standard drawing window will appearwith an animation of 20 colliding disks.To get your command prompt back, close the standard drawing window.Frequently Asked Questions |
Nero multimedia suite 10 crack.
/var/log/lift.log
.e5ef947039280e0b0520fd7bd3aff8a0373719b96b1745c08a42441f6554fafe
sudo installer -verbose -pkg lift-java.pkg -target /
/Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/
/Applications/IntelliJ IDEA CE.app
~/Library/Application Support/JetBrains/IdeaIC2020.1/
~/Library/Caches/JetBrains/IdeaIC2020.1/
~/Library/Logs/JetBrains/IdeaIC2020.1/
/usr/local/lift/
/usr/local/bin/javac-{algs4,introcs}
/usr/local/bin/java-{algs4,introcs}
/usr/local/bin/jshell-{algs4,introcs}
/usr/local/bin/spotbugs
/usr/local/bin/pmd
/usr/local/bin/checkstyle
11
,but the rest is not critical.The course-specific project folders perform additional customizations:
java.lang
,java.util
, and algs4.jar
).algs4.jar
)./Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/
.To manually configure the Project SDK,
.iml
file (which defines the project),the .idea
subdirectory (which containsthe IntelliJ course preferences), andthe .lift
subdirectory (which contains the courselibraries).To create a new project from scratch, you can use the Create New Project option from theWelcome screen. But, we do not recommend this approach for novice programmers.
javac-algs4
or java-algs4
.javac-algs4
andjava-algs4
)should already be available.Our autoinstaller customizes the command line in a few ways by copying these three configuration files:.bashrc
,.bash_profile
, and.inputrc
.Note that the autoinstaller will copy these files only if none of them already exists.If you had previous versions and wish to replace your versions with ours, type the following commands:
Ctrl-C
.Enter
Ctrl-D
.On Windows, type Enter
Ctrl-Z
Enter
,even in Git Bash..class
files.Here is a list ofbug descriptions..java
file ora directory containing one or more .java
files.Here is a list of bug patterns..java
files.Here is a list ofavailable checks.