Java El Capitan

Posted on  by 

Macs do not include Java by default so you have to download and install Java on El Capitan, Sierra and High Sierra separately. One of the most common problems users have after upgrading to El Capitan, Sierra or High Sierra is an error message when trying to access certain websites or run apps that require Java and this tutorial helps fix that. There are also issues regarding legacy support for Java 6 in macOS 10.12 Sierra which we clarify at the end of the article. Note that we don’t recommend you install Java unless absolutely essential because it’s notoriously unstable and insecure and once installed, you can’t ever fully uninstall Java from a Mac. However, if you’re one of those people that has no choice because the website you need to access, application you want to use or the game you want to play requires it, follow these instructions.

How To Install Java On El Capitan, Sierra & High Sierra

If you’ve upgraded to El Capitan,macos Sierra or High Sierra and keep receiving the error message pop up:

As it states in the Verified Java Version web page, Java 8 Update 40 is installed on this Mac. If your Java is not working properly, the Test Java page displays additional configuration options that you may need to check, as well as download and installation instructions if needed.

Apple has posted notice that Mac OS X 10.11 (El Capitan) will be the last OS X release that supports Java 6, and as such, recommends developers whose applications depend on Java 6 to migrate their apps to a newer Java version provided by Oracle. I got it working by adding to /.profile. Somehow after updating to El Capitan beta, it didnt work even though JAVAHOME was defined in.bashprofile. If there are any El Capitan beta users, try adding to.profile. When I try installing that same java fix I get the following Error: Java for OS X can’t be installed on this disk. A newer version of this package is already installed. Any thoughts and help will be greatly appreciated! How to solve this problem? 1: Download Java 6 for El Capitan: Java for OS X 2015-001 Beta. Apple has posted notice that Mac OS X 10.11 (El Capitan) will be the last OS X release that supports Java 6, and as such, recommends developers whose applications depend on Java 6 to migrate their apps to a newer Java version provided by Oracle.

To use the “java” command line tool you need to install a Java SDK

It’s because an application you have installed or a website you’re trying to access requires Java to launch or work properly. If you’ve never installed Java on Mac, then you can simply download and install the latest version of Java from Oracle which is known as Java 8 but rather confusingly officially called Java 1.8 by Oracle.

If you’re not sure whether Java is installed on your Mac, simply search for Terminal in Spotlight and type: java -version at the command prompt.

If Java is on your Mac, you’ll see a message saying something like “Java (TM) Runtime Environment” in this case version 1.6 (or Java 6 as it is commonly known). If you find that you already have Java 1.6 installed, scroll down below “How to update Java 6 in El Capitan” as you also need to install a special update from Apple.

Java Installation Problems in El Capitan, Sierra & High Sierra

If you run into problems during the installation of Java, it’s because Apple has added an extra layer of security to Macs known as Rootless SIP. Java has such a bad rep on Macs that Apple has made it increasingly difficult to install it and other things that can potentially damage OS X. If your Mac is blocking the installation of Java, follow these instructions to disable rootless SIP and try again:

  • Restart your Mac when the screen turns black hold down ⌘R until the Apple logo appears.
  • Select the “Utilities” menu and then “Terminal”. In Terminal type: csrutil disable
  • Hit Return and then restart OS X. Your Mac will then restart with SIP disabled and you can try installing Java again.
  • To re-enable System Integrity Protection, follow exactly the same procedure except type: csrutil enable
  • Rootless SIP is then renabled on your Mac.

Note: You will have to deactivate SIP when new updates for Java are released as Java will not update while SIP is enabled.

How To Update Java 6 On Mac

If you find that Java apps or applets will either refuse to run or open briefly before crashing giving you an error message such as “This application requires the legacy Java SE 6 runtime which is unavailable for this version of OS X”:

or the Java applet crashes with an error message such as:

com.apple.xpc.launchd[1]: (com.apple.xpc.launchd.oneshot.0x10000004.OSXJavaLauncher[395]) Service exited with abnormal code: 1

It’s because some applications, games and websites still only work with Java 6. Examples of people that may still need Java 6 are those trying to access some government sites, some online games and Android programmers that require Java 6 to develop Android apps on Mac. If you’re having problems running Java 6 on your Mac in El Capitan then you simply need to install Apple’s legacy Java 6 OS X 2015-001 update. This is a special update from Apple which allows the outdated Java 6 to safely run on your Mac. In the release notes for the Java 6 update, Apple states:

Java for OS X 2015-001 installs the legacy Java 6 runtime for OS X 10.11 El Capitan, OS X 10.10 Yosemite, OS X 10.9 Mavericks, OS X 10.8 Mountain Lion, and OS X 10.7 Lion. This package is exclusively intended for support of legacy software and installs the same deprecated version of Java 6 included in the 2014-001 and 2013-005 releases.

To install the update, you must quit any Java applications that are running and then simply download and double click on the Jave 6 update file and the update will automatically install. If you run into problems during installation, you’ll need to disable Rootless SIP protection in OS X (see above). Note that Java 6 does not officially work with OS X 10.12 Sierra although some users have had success with it so it may work and it seems to depend on the specific app you need it for.

Note: Do not get Java confused with JavaScript! JavaScript is an essential component for most browsers that enables it to display certain elements properly and is completely different to Java despite the confusingly similar name. Disabling JavaScript will mean many websites simply won’t work in your web browser anymore.

Support For Java 6 In Sierra

The bad news for those that need Java 6 on macOS 10.12 Sierra is that it is no longer officially supported on anything higher than OS X 10.11 El Capitan. Due to various security and support issues, last year Apple announced plans to discontinue any support for Java 6 in future versions of OS X:

OS X v10.11 is the last major release of OS X that will support the previously deprecated Java 6 runtime and tools provided by Apple. Applications or features that depend upon Java 6 may not function properly or will not launch when Java 6 is removed. Developers should move to a newer version of Java as provided by Oracle.

However the Apple link that Oracle refers users to has now been removed by Apple leaving some doubt as to whether Apple has had a change of heart regarding support for Java 6 on Sierra. Some Mac users are reporting that you can still install Java 6 on Sierra and it works for some apps but not for others. In the case of Cyberduck for example, it seems that the developer has updated the app to work with Java 6 in Sierra so it may well be down to individual developers whether they force their apps to work with it. Our advice is don’t rely using Java 6 on Sierra until Apple clarify whether it will be officially supported. Java 7 and 8 are officially supported in OS X 10.12 Sierra and if you don’t need Java 6, we highly recommend updating to Java 7 or 8 because Java is notoriously insecure and older versions are particularly vulnerable to attack and bugs.

As stated in the introduction, if it’s not necessary to you, you’re better off not installing Java at all on your Mac as it’s an increasingly antiquated platform that often causes more problem’s than it’s worth. And you can never fully remove Java from a Mac although you can find instructions how to disable Java on your Mac here.

If you have any other problems running Java in El Capitan, Sierra or High Sierra on your Mac, let us know in the comments below.

I would like to use the WatchService API as mentioned in this link:http://download.oracle.com/javase/tutorial/essential/io/notification.html

After reading around, I found out that WatchService is part of the NIO class which is scheduled for JDK 7. So, it is in beta form. It's fine.

http://jdk7.java.net/download.html has the JDK which I downloaded and extracted. I got a bunch of folders. I don't know what to do with them.

Then, I read around some more and found that some nice group of people created JDK 7 as a binary so someone like me can install it easily. It is called Open JDK:http://code.google.com/p/openjdk-osx-build/

So, I downloaded the .dmg file and install it. Then I open 'Java Preference' and see that OpenJDK7 is available.

So, now I feel that I can start trying out WatchService API. From the tutorial in the first link, the author gave a .java file to test it out first and make sure that it is running. Here is the link to the file:http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java

So, I boot up Eclipse (actually I use STS) and create a new Java project and choose JaveSE-1.7 in the 'use an execution environment JRE:'. Under the src folder, I copy pasted the WatchDir.java file.

And I still see tons of squiggly red lines. All the 'import.java.nio.*' are all red and I cannot run it as a Java app.

What do I need to do?

Zoe
15.6k12 gold badges65 silver badges96 bronze badges
okysabeniokysabeni

What Java Do I Download For Minecraft

4,21313 gold badges57 silver badges76 bronze badges

14 Answers

Ben S
58.4k25 gold badges157 silver badges206 bronze badges

This is how I got 1.7 to work with Eclipse. I hope it helps.

  1. I Downloaded the latest OpenJDK 1.7 universal (32/64 bits) JDKfrom Mac OS/X branch from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
  2. copied the jdk to /Library/Java/JavaVirtualMachines/ next to thedefault 1.6.0 one
  3. In Eclipse > Preferences > Java > Installed JREs you add a new one, of type MacOS X VM, and set the home as /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home andname Java SE 7 (OpenJDK)
  4. Click Finish
  5. Set the added JRE as default

that should be it :)

vectorsizevectorsize
1,0151 gold badge7 silver badges6 bronze badges

Years ago, Apple joined the OpenJDK project, transferring their formerly proprietary macOS-specific JVM code as free-of-cost open-source. Apple ceased distribution of their own branded JVM/JDK, relying on Oracle’s branded releases to include a version for macOS.

Oracle has recently announced their intention to bring their Oracle-branded JVM release to feature parity with the OpenJDK project, with virtually the same code base. The company even donated their previously commercial tools, Flight Recorder & Mission Control, to the OpenJDK project. This is part of the shift to a new rapid “release train” plan for predictably scheduled versioning of Java and OpenJDK. Notably, the periods for free-of-cost public updates is now shortened. See this 2017-09 announcement and this posting by Mark Reinhold.

As a result of all this, macOS users of Java have a choice of vendors for a Java implementation. At this point, at least three sources are based on OpenJDK for macOS:

  • Oracle releases of the JDK and JRE, with optional paid support.
  • Azul Systems releasing:
    • Zulu line of free-of-cost JVMs with optional paid support.
    • Zing line of commercial JVMs with special features such as an alternate garbage-collector.
  • OpenJDK source code, roll-your-own compilation & installation (perhaps not practical for most of us).

Meanwhile, IBM donated code for a JVM to the Eclipse Foundation, now housed in the OpenJ9 project. I wonder if they might support a macOS release as well, though it is too soon to tell.

Personally, I am currently using the Zulu release of Java 10.0.1 from Azul on macOS High Sierra successfully with IntelliJ 2018.2 to produce Java-backed web apps with Vaadin.

Java El Capitan Download

Installation/Removal

Both Oracle and Azul provide utterly easy-to-use installers to install the JVM/JDK on your Mac. Verify your installation by using the Terminal.app (or equivalent) to type and run:

You will find the Java installations in this folder at the root level of your drive (not in your home folder):

/Library/Java/JavaVirtualMachines

Each version from each vendor is found there, in a labeled nested folder. You can delete any installation simply by deleting the nested folder for that version and providing your system password when prompted.

You can download the Java Development Kit (JDK) for Java 8 for the supported versions of Mac OS X:

  • Mountain Lion (10.8.3+)
  • Mavericks (10.9)
  • Yosemite (10.10)
  • El Capitan (10.11)

Each version of JVM you install can be found here:

For more instructions and FAQ, see this Oracle Guide.

For every release of Java 7 since Update 4, a Mac version has been ready alongside the other platforms. Runs on Macs with 64-bit hardware on Lion (10.7.3+), Mountain Lion (10.8.3+), and Mavericks (10.9.x).

Oracle announced the official release of the JDK for Java SE 7 Update 4 on Mac OS X (Lion), as of 2012-04-26. No more need for the tricks discussed on this page.

Installation is simple per these instructions:

Which Java Do I Download

  1. Download from the usual place on the Oracle web site.
  2. Mount the DMG.
  3. Run the installer.

This release has a few limitations, most notably the lack of support for Java Web Start and the Java Plugin for web browsers. That support is expected later this year.

After installing, read the JDK for Mac ReadMe. Most importantly, if you want Java 7 to be the default, drag it to the top of the list in the Java Preferences app found in your Utilities folder.

Mac OS X easily supports multiple JVMs simultaneously. Each is now found here:

Congratulations to the Apple & Oracle teams for their achievement. This geek gets a thrill seeing Mac OS X listed as a 'Certified System Configuration'.

Tip: To start Eclipse on a Mac with only Java 7 installed, open the alias file named eclipse rather than the file named Eclipse.app.

Apple continues to supply an up-to-date implementation of Java 6 for all versions of Mac OS X up through Mountain Lion.

If you do something that requires Java, such as type 'java -version' in Terminal.app, a dialog appears offering to install Java for you. If you accept, installation happens automatically similar to other 'Software Updates' from Apple.

You will find Java installed in this location, different than Java 7 & 8:

Java 6 has reached end-of-life with Oracle as of 2013-02 (unless you have a commercial support agreement with Oracle). So you should be moving to Java 7 or 8.

In Terminal.app, type java -version to verify which version is the current default.

After installing a fresh version, you may want to visit the folder described above to delete old versions. Move the folder to the Trash, and provide your System password complete the move.

By the way, Apple provides a mailing list for developers’ technical issues related to Java on OS X.

Basil BourqueBasil Bourque
131k38 gold badges438 silver badges618 bronze badges

An easy way to install Java 7 on a Mac is by using Homebrew, thanks to the Homebrew Cask plugin (which is now installed by default).

Run this command to install Java 7:

AndrewAndrew
105k165 gold badges466 silver badges648 bronze badges

I know that some may want to smack me for re-opening old post, but if you feel so do it I just hope this may help someone else trying to set JDK 7 on Mac OS (using IntelliJ).

What I did to get this working on my machine is to:

  • followed instructions on Oracle JDK7 Mac OS X Port for general installation
  • in IntelliJ open/create new project so you can add new SDK (File > Project Structure)
  • select Platform Settings > SDKs, press '+' (plus) sign to add new SDK
  • select JSDK and navigate to /Library/Java/JavaVirtualMachines/JDK 1.7.0 Developer Preview.jdk/Contents/Home. Do not get it mistaken with /Users/YOUR_USERNAME/Library/Java/. This will link 4 JARs from 'lib' directory (dt.jar, jconsole.jar, sa-jdi.jar and tools.jar)
  • you will need also add JARs from /Library/Java/JavaVirtualMachines/JDK 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib (charsets.jar, jce.jar, JObjC.jar, jsse.jar, management-agent.jar, resources.jar and rt.jar)
peter_budopeter_budo
1,4754 gold badges21 silver badges43 bronze badges

Get cask

Install java7:

(I had difficulty finding the download link of java7 on oracle website, as they're just 'recommending' java8 )

EDIT January 2018(As pointed by Ankur):

Use zulu7 cask. Zulu is a certified build of OpenJDK produced by Azul Systems that should be around for a long time (they even offer JDK6 builds still).

It's possible that you still need to add the JDK into Eclipse (STS). Just because the JDK is on the system doesn't mean Eclipse knows where to find it.

Go to Preferences > Java > Installed JREs

If there is not an entry for the 1.7 JDK, add it. You'll have to point Eclipse to where you installed your 1.7 JDK.

If Eclipse can't find a JRE that is 1.7 compatible, I'm guessing that it just uses your default JRE, and that's probably still pointing at Java 1.6, which would be causing your red squiggly lines.

Jon QuarfothJon Quarfoth

after installing the 1.7jdk from oracle, i changed my bash scripts to add:

and then running java -version showed the right version.

Java Se 6 For El Capitan

Dustin GetzDustin Getz
13.5k11 gold badges69 silver badges123 bronze badges

How about Netbeans, here is an article how to set it up with NB7:

Java For Mac Os X El Capitan

Maybe similar steps for Eclipse.

As of April 27th there is an offical Oracle release of Java SE 7u4. Download the disk image and run the installer - then see the Mac readme.

MarkMark
28.9k10 gold badges83 silver badges105 bronze badges

The instructions by peter_budo worked perfectly. I had to add the jars under /Library/Java/JavaVirtualMachines/JDK 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib/ to my IntelliJ project libraries. Now it works like a charm. Note that I didn't need my IDE itself to run under 1.7; rather, I only needed to be able to compile and run against 1.7. I'll most likely continue to use Apple's JRE for running the IDE since it's probably more stable with respect to graphics routines (Swing, AWT). Like the OP, I was really keen on testing out the new NIO2 API. Looking good so far. Thanks, Peter.

What worked for me on Lion was installing the JDK7_u17 from Oracle, then editing ~/.bash_profile to include: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home

user1015892user1015892

As of December 2017, previously posted links don't work, but JDK 7 can still be downloaded from Oracle Archives (login required):

ozren1983ozren1983
1,3831 gold badge13 silver badges29 bronze badges

I updated to Yosemite and Android Studio wouldn't clean my projects or Run them on virtual or real device because of the following error:

After some research and trouble shooting, I found that the JDK file that was being pointed to at '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home' wasn't there; all of 'JavaVirtualMachines/1.6.0.jdk/Contents/Home' was missing from '/System/Library/Java'. So, I copied 'JavaVirtualMachines/1.6.0.jdk/Contents/Home' over from '/Library/Java/' to '/System/Library/Java/' and cha ching! I was back in business.

embersofadyingfireembersofadyingfire
2301 gold badge3 silver badges15 bronze badges

Not the answer you're looking for? Browse other questions tagged macosjavajava-7 or ask your own question.


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.

Java El Capitan

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 2021.1.

  • Log in to the user account in which you will be programming.Your account must have Administrator privileges.
  • Download the Mac OS X installerlift-java.pkg.
  • Double-click lift-java.pkg to install the software.Enter your Mac OS X password when prompted and use all of the default options.

    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 andthe accompanying user settings.

    Also, by default, the installer overwrite any pre-existing Bash configuration files,such as .bashrc.If you wish to keep yours, see the FAQ.

  • Delete lift-java.pkg (if it is not automatically deleted).

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).

  • Download the project for your programming assignment to a convenient location(such as the Desktop).

    [ sample project for COS 126 (Princeton) ]

    [ sample project for COS 226 (Princeton) ]

    [ sample project for Computer Science: Programming with a Purpose (Coursera) ]

    [ sample project for Algorithms, Part I or II (Coursera) ]

    Double click the zip file to unzip.This creates a project folder with thename of the corresponding programming assignment (such as hello).Delete the zip file.


    Warning

    The project folders contain course-specific information. Be sure to downloadthe one corresponding to your institution and course.


  • Launch IntelliJ via Finder → Applications → IntelliJ IDEA CE.app.
  • When you launch IntelliJ for the first time,
    • IntelliJ may displaytheJetBrains privacy policy.Scroll down and Accept.
    • IntelliJ may ask if you want to send anonymous usage statistics to JetBrains. Choose your preferred option.
    • IntelliJ will display the Welcome to IntelliJ IDEAscreen.
  • To open a project from the Welcome to IntelliJ IDEA screen,click Open and select the project folder.You should see an assignment logo (in the main editor window) and a list of project files (in the Project View sidebar at left).
    When you launch IntelliJ for the first time,it may take a minute or two to index your files;some features (such as auto importing) will be unavailable until this process completes.


    Warning

    Do not click New Project;this option is intended for advanced programmers.Also, always use Open with a project folder, not an individual file.

  • When you are finished working, select the menu optionIntelliJ IDEA → Quit IntelliJ IDEA (⌘Q) to exit IntelliJ.The next time you launch IntelliJ, your recent projectswill appear in the Welcome to IntelliJ IDEA screen for easy access.

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.

  • To create a new Java program:
    • Re-open IntelliJ and the project (if you closed it in the previous step).
    • Click the project name in the Project View sidebar (at left), so that itbecomes highlighted.


    • Select the menu option LIFT → New Java Class.When prompted, type HelloWorld for the Name and click OK.


  • In the main editor window, complete the Java programHelloWorld.java exactly as it appears below.(IntelliJ generates the gray boilerplate code automatically,possibly with the addition of a course header block comment.)If you omit even a semicolon, the program won’t work.
  • As you type, IntelliJ highlights different syntactic elementsin different colors.When you type a left bracket, IntelliJ adds the matching right bracket.When you begin a new line, IntelliJ indents it.


  • To save the file, select the menu option File → Save All (⌘S).When you save the file, IntelliJ re-formats it (as necessary).


    Tip

    IntelliJ is configured to automatically save changes that you make to your files upon various events (such as compiling, executing, closing a file or project,or quitting the IDE).We still recommend using File → Save All (⌘S)to re-format your code.


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.

  • Select the program that you wish to compile and execute in the the Project View sidebar. The program should now appear in the main editor window.
  • To compile your program,select the menu optionLIFT → Recompile 'HelloWorld.java' (⌘B).If the compilation succeeds, you will receive confirmationin the status bar (at bottom).

    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.

  • To execute your program,select the menu option LIFT → Run 'HelloWorld' with Arguments (⌘E).Since this program takes no command-line arguments, click OK.

    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.

Java Download For Mac El Capitan

  • Select the menu option View → Tool Windows → Terminal (⌘2).
  • This will launch a Bash terminal where you type commands.You will see a command prompt that looks something like this:

    The ~/Desktop/hello is the current working directory, where~ is shorthand for your home directory.

  • To compile your program,type the following 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.
  • To execute your program,type the following 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.

  • Computer Science: An Interdisciplinary Approach (including COS 126 students).The programBarnsley.javauses our standard drawing and standard random libraries in 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.

  • Algorithms, 4th Edition (including COS 226 and Coursera students).The programCollidingDisks.javauses various libraries in algs4.jarto 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



    I installed IntelliJ and Java using thelift-java.pkg installerlast semester or year. Should I rerun this semester?
    Yes. This installer includes IntelliJ 2021.1and Java 11.The old installer may have used an earlier version of IntelliJ or Java.
    What happens if I rerun the lift-java.pkg installer?
    It will re-install and re-configure OpenJDK 11, IntelliJ,SpotBugs, PMD, Checkstyle, our textbook libraries,and wrapper scripts.
    I want to install only a subset of the components. How can I accomplish this?
    Run the installer. On the Installation Type screen, click Customizeand mark the desired components:
    • OpenJDK 11: installs Java.
    • Command-Line Tools: installs wrapper scripts likejavac-introcs and javac-algs4.
    • Bash Configuration Files: installs our .bashrc,.bash_profile, and.inputrc files.
    • IntelliJ IDEA, Community Edition 2021.1: installs IntelliJ with our novice-friendly user preferences.

    Typically, we recommend a full install. A custom install can be useful if you already have a specialized.bashrc file.It might also speed things upif you need to re-install, say IntelliJ IDEA, Community Edition 2021.1, but not Java.

    The installer overwrote my specialized .bashrc file. How can I revert to the original version?
    If you didn't want this to happen, it's best to unmark the Bash Configuration Files component during installation, as described in the previous question.If it's too late for that, the autoinstallercreates a backup copy of your .bashrc file by appendinga timestamp to the filename, e.g., .bashrc.20210706-191748.
    The installer failed. How can I investigate why?
    Check the installer log at /var/log/lift.log.
    I have Mac OS X 10.12 (Sierra). Is that too old?
    Yes, sorry. IntelliJ 2021.1 requires Mac OS X 10.13 (High Sierra) or newer.
    How long will the installer take to complete installation?
    Once downloaded, it should take about a minute.If you have anti-malware protection software running (such as McAfee Endpoint), it couldtake 5–10 minutes.
    What does the lift-java.pkg installer do?
    In short, it installs and configures Java, IntelliJ,SpotBugs,PMD,Checkstyle,and our textbook libraries,along with accompanying command-line tools.Here is a more detailed list:
    • Installs OpenJDK 11.0.11.
    • InstallsIntelliJ 2021.1.3with novice-friendly user preferences.
    • Installs the following command-line tools for Java:
      • The textbook librariesstdlib.jar andalgs4.jar.
      • Java wrapper scripts, includingjavac-algs4 andjava-algs4.
      • Custom.bashrc,.bash_profile, and.inputrc files.
      • SpotBugs 4.2.3;our SpotBugs configuration filespotbugs.xml;and wrapper script spotbugs.
      • PMD 6.34.0;our PMD configuration file pmd.xml;and wrapper script pmd.
      • Checkstyle 8.31;various configuration files(checkstyle-cos126.xml,checkstyle-cos226.xml,checkstyle-coursera.xml, andcheckstyle-suppressions.xml);custom checks checkstyle-lift.jar;and wrapper script checkstyle.
    How is the software licensed?
    All of the included software is licensed under various open-source licenses.
    • IntelliJ IDEA, Community Edition is licensed under theApache License, Version 2.0.
    • OpenJDK 11 is licensed under theGNU General Public License,version 2, with the Classpath Exception.
    • SpotBugs is licensed under theGNU Lesser Public License, Version 2.1.
    • Checkstyle is licensed under theGNU Lesser Public License, Version 2.1.
    • PMD is licensed under a BSD-style license.
    • stdlib.jar and algs4.jar are licensed under theGNU General Public License, Version 3.
    What’s the sha256sum of lift-java.pkg?
    2d554fe9c63aa89e3d56b83424e1a2c55dd5d3218c1761e25967a12fc313f5b5
    Can I run the installer from the command line?
    Yes. Use the command sudo installer -verbose -pkg lift-java.pkg -target /
    How can I uninstall the software?
    • To uninstall OpenJDK 11,delete the following directory:
      • /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/
    • To uninstall IntelliJ, delete the following:
      • /Applications/IntelliJ IDEA CE.app
      • ~/Library/Application Support/JetBrains/IdeaIC2021.1/
      • ~/Library/Caches/JetBrains/IdeaIC2021.1/
      • ~/Library/Logs/JetBrains/IdeaIC2021.1/
    • To uninstall SpotBugs, PMD, Checkstyle,and our textbook libraries, delete the following directory:
      • /usr/local/lift/
    • To uninstall our wrapper scripts, delete the following files:
      • /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
    Java FAQ
    Can I use a vendor and version of Java other than OpenJDK 11?
    Yes.You may use any version of Java 8 or newer from either Oracle or OpenJDK.However, if you do so, you will need to manually configure the Platform SDK and Project SDK viaIntelliJ via File → Project Structure.We recommend sticking to the long-term support (LTS) versions: Java 8, Java 11, and Java 17.
    How can I check which version of Java is installed (and where it is installed)?
    Type the following commands in the terminal:It’s important that the Java version numbers match and that you see the number11,but the rest is not critical.
    How does this custom version of IntelliJ different from the standard one?
    IntelliJis an industrial-strength integrated development environment (IDE),suitable for use by professional programmers.The installer configures your user preferences to make itmore suitable for use by novice programmers:
    • Disables all built-in plugins except Terminal and JUnit. Installs the SpotBugs, Checkstyle-IDEA, Run-with-Arguments, Save-Actions, and Archive browser plugins.
    • Eliminates or reduces various popup elements (lightbulbs, code folding, breadcrumbs, gutter markers, notifications, parameter hints).
    • Simplifies menus and toolbars, hiding advanced options.
    • Disables live templates and postfix completion.
    • Adopts the Obsidian Black color scheme.
    • Auto-configures Java upon installation.
    • Adds a few keyboard shortcuts.

    The course-specific project folders perform additional customizations:

    • Streamlines autocomplete to display only relevant libraries(such as java.lang,java.util, and algs4.jar).
    • Configures SpotBugs and Checkstyle with course-specific rules.
    • Provides course-specific libraries (such as algs4.jar).
    • Enables auto-formatting of code on save.
    • Enables auto-importing of Java libraries.
    How can I manually configure the Platform SDK and Project SDK in IntelliJ?
    The installer should configure the Platform SDK automatically.To configure it manually,
    • Navigate to File → Project Structure → Platform Settings → SDKs.
    • Click the + symbol (top left) to add an SDK.
    • Locate an SDK. A typical location for a Java SDK onMac OS X is /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/.
    • Use the shorthand name suggested by IntelliJ(e.g., 11 for version 11.0.11).

    To manually configure the Project SDK,

    • Navigate to File → Project Structure → Project Settings → Project.
    • Choose the desired Project SDK from the drop-down list.
    • Be sure to use 8 as the Project language level, as our autogradercurrently supports only Java 8 features.
    Which are the most important IntelliJ menu options to remember?
    Here are the most important ones (and their shortcuts).
    • LIFT → New Java Class (⌘N). Create a new Java class.
    • LIFT → Recompile (⌘B). Compile the current program.
    • LIFT → Run with Arguments (⌘E). Run the current program with command-line arguments.
    • LIFT → Open in Terminal (⌘T). Open a new Terminal tab.
    • File → Save All (⌘S). Save (and reformat) all open files.
    • View → Tool Windows → Project (⌘1). Show/hide the Project View sidebar.
    • View → Tool Windows → Terminal (⌘2). Show/hide the Terminal window.
    Any special characters to avoid when naming IntelliJ projects or files?
    Do not use an exclamation mark ! as the last characterin the project folder (or any directory name along the path to your project folder);that will confuse both IntelliJ and Checkstyle.
    How can I create a new project in IntelliJ?
    If you want to inherit all of the properties of an existing project,
    • Use the Finder to copy the project folder,giving it your preferred name.
    • Delete any unwanted files.
    • Be sure to keepthe .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.

    Can I use a version of IntelliJ that is more recent than 2021.1.3?
    Yes, though if it is 2021.2 (or above),you will need to migrate your user preferences.
    How I can I restore the original IntelliJ settings(instead of the abbreviated novice-friendly ones)?
    • To restore the menus and toolbars: Preferences → Appearances & Behavior → Menus and Toolbars → Restore All Defaults.
    • To restore all settings: Help → Find Action → Restore Default Settings.
    Command-Line / Embedded Terminal FAQ
    When I compile or execute a program from the command line that uses one of thetextbook libraries, I get an error that it cannot find the library. How can I fix this?
    Make sure that you are using the appropriate wrapper script,such as javac-algs4or java-algs4.
    How should I configure Bash?
    If you followed our instructions, our wrapper scripts (such asjavac-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.

    How do I break out of a program in an infinite loop?
    Type Ctrl-C.
    How do I specify EOF to signal that standard input is empty?
    On Mac OS X and Linux, type EnterCtrl-D.On Windows, type EnterCtrl-ZEnter,even in Git Bash.
    How can I run SpotBugs, PMD, and Checkstyle from the command line?
    The installer includes wrapper scripts to simplify this process.
    • To run SpotBugs 4.2.3, type the following command in the terminal:The argument must be a list of .class files.Here is a list ofbug descriptions.
    • To run PMD 6.34.0, type the following command in the terminal:The argument must be either a single .java file ora directory containing one or more .java files.Here is a list of bug patterns.
    • To run Checkstyle 8.31, type one ofthe following commands in the terminal, depending on whether you are COS 126, COS 226, or Coursera student:The argument must be a list of .java files.Here is a list ofavailable checks.
    How can I change the default shell in the Terminal application from zshto bash?
    Beginning with OS X 10.15 (Catalina), the default shell is zsh.To change it to bash, type the following commandinto the Terminal application and enter your OS X password:Finally, close the Terminal application and reopen it.Note that the embedded terminal within IntelliJ isconfigured to use bash regardless ofthe default shell for the Terminal application.

Coments are closed