-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up Unix for Java Development
Depending on whether you are using a Windows or Mac machine, choose ONE of the following set-ups:
Then test your setup with jshell:
- Hit ⊞ Win to open the Start menu, type
PowerShelland press Enter.
Scoop is a command-line software manager for Windows.
Run the following commands in the PowerShell window one at a time:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserirm get.scoop.sh | iexTo ensure that each command is entered correctly, you may
- copy the command above by selecting it and then hitting Ctrl + C
- go to the PowerShell window and paste the command above by hitting Ctrl + V . Press enter to run the command.
Install the busybox windows binary for the set of common Unix tools.
Run the following command in the PowerShell window:
scoop install busyboxInstall either the vim or micro editor. The latter is more user friendly.
Assuming you are installing micro, run the following command in the PowerShell window:
scoop install microRun the following commands in the PowerShell window one at a time:
scoop bucket add java
scoop install openjdk21After all installation is completed, hit ⊞ Win to open the Start menu, type bash and press enter.
To open a File Explorer Window that points to the current directory, enter the following command in the bash window:
explorer.exe .
Note the trailing dot at the end. This will be useful when you select your program for submission to CodeCrunch later.
Since the macOS is a Unix-based operating system, there is no setup required.
To access the Unix command line interface, hit F4 to access LaunchPad, and type Terminal followed by enter .
Run the following command within Terminal to install a set of command-line tools used for software development in macOS.
xcode-select --installHomebrew is a command-line software manager for macOS.
If you have not installed Homebrew before, paste the following into your shell to install it.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"Run the following command in Terminal:
brew install openjdk@21
If the above does not work, then most likely you have a newer Mac machine. In this case, run the following commands instead:
/opt/homebrew/bin/brew shellenv
brew install openjdk@21
To open a Finder Window that points to the current directory, enter the following command in Terminal:
open .
Note the trailing dot at the end. This will be useful when you select your program for submission to CodeCrunch later.
In your Unix environment (msys or WSL2) for Windows, or Terminal for MacOS, type jshell
at the Unix prompt (denoted as $ below):
$ jshell
| Welcome to JShell -- Version 21.0.2
| For an introduction type: /help intro
jshell>
Enter 1 + 1 at the jshell> prompt. It should return 2.
$ jshell
| Welcome to JShell -- Version 21.0.2
| For an introduction type: /help intro
jshell> 1 + 1
$1 ==> 2
jshell>
Now type /exit to quit jshell:
$ jshell
| Welcome to JShell -- Version 21.0.2
| For an introduction type: /help intro
jshell> 1 + 1
$1 ==> 2
jshell> /exit
| Goodbye
Here's a tip: if you are interested in the list of JShell commands, you can type /help at the jshell> prompt.