Skip to content

Instantly share code, notes, and snippets.

@StuartsHome
Last active March 8, 2021 18:09
Show Gist options
  • Select an option

  • Save StuartsHome/8acea5abaf70354eb51728b0fe89e33c to your computer and use it in GitHub Desktop.

Select an option

Save StuartsHome/8acea5abaf70354eb51728b0fe89e33c to your computer and use it in GitHub Desktop.
Installation of Java on macOS
Install JDK - also installs JRE
1. Verify if Java is installed
1.1 In Terminal type: $ java -version
2. Install Java JDK
2.1 Open .dmg folder
2.2 Open .pkg folder
3. Set Java Home env variable
3.1 Quit Terminal and re-open to refresh session
3.2 Query current java home path using Commands 1.
3.3 Open ~/.bash_profile
3.3.1 Possible to use 'ls -al' command in Terminal to show hidden files
3.4 Export Path - export JAVA_HOME = <pathfromCommand1.>
4. At Terminal, refresh bash profile using - $ source ~/.bash_profile
5. Echo Java_home - $ echo JAVA_HOME
5.1 Or, $ java -version
5.2 Or, $ javac -version
Compile, and run, app to verify Java installed:
1. In Terminal, $ touch HelloWorld.java
2. Open file, create simple class
3. In Terminal, compile to create class files - $ javac HelloWorld.java
4. In Terminal, run file - $ java HelloWorld
Commands:
1. To see Java home path - /usr/libexec/java_home -v15
Github SSH
To verify SSH:
1. ssh -T [email protected]
Troubleshooting:
Error - Unbound classpath container: 'JRE System Library [JavaSE-15]' in project 'spring-steps'
1. First query home env variable - $ $JAVA_HOME
2. Show location of JDK - $ /usr/libexec/java_home -v
3. Copy path into VScode - In VScode - click user settings
3.1. add '"java.home":"absolutepath"
3.2. Save the settings
4. In command palette:
4.1. Enter - Java: Configure Java Runtime
4.2. Download latest JDK versions for both Project and Java Tooling Runtime
5. Refresh VScode in Command Palette with - reload window
6. Link - https://medium.com/@tariqul.islam.rony/learning-java-and-spring-boot-with-visual-studio-code-vscode-part-1-54073f2fa264
Java home is not used by Java - but is used by third party apps like TomCat.
7. Set Java home:
7.1. Query the path - $ /usr/libexec/java_home -v
7.2. Open bash profile
7.3. Add - export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
Query JDK in VSCode:
In command palette - Java: Configure Java Runtime
To use JUnit5 without Maven or Spring
Add the Jar to the lib folder:
- $ junit-platform-console-standalone-1.7.0-M1.jar
Maven
Forces check for missing releases and updated snapshots - Hamid command:
- $ mvn clean install -U
To test:
- mvn test
Help:
- $ maven -h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment