Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Java Tools

Java Tools

Introduction to Java technologies and tools.

Jussi Pohjolainen

December 14, 2021
Tweet

More Decks by Jussi Pohjolainen

Other Decks in Technology

Transcript

  1. Java as a Platform • Java SE for Desktop •

    JRE does not come bundled with Windows or Mac OS X. In Linux, it depends on the distribution. • Java EE for Enterprise • Platform for developing backend services • Good compability with legacy systems • Web servers, application servers • Java ME for Mobile • Android uses Java language (Altough Kotlin is preferred), but does not support Java ME! • Support today....? 2
  2. Java/Jakarta EE • Oracle: Java Enterprise Edition (Java EE) 8

    • Former name: Java 2 Platform Enterprise Edition (J2EE) • Set of specifications for enterprise applications • Java EE apps runs on application servers • https://javaee.github.io/tutorial/toc.html • Eclipse Foundation: Jakarta EE 8 • From 2019 Java EE was rebranded to Jakarta EE • Oracle does not maintain Java EE anymore • Eclipse does not own trademark Java, so Jakarta is used • https://eclipse-ee4j.github.io/jakartaee-tutorial/toc.html • Spring Boot is maybe more popular choice for backend
  3. Year Java Version 2004 J2SE5 2006 (2 years) Java SE

    6 2011 (5 years) Java SE 7 2014 (4 years) Java SE 8 (LTS) 2017 September (3 years) Java SE 9 2018 March (6 months) Java SE 10 2018 September (6 months) Java SE 11 (LTS) 2019 March (6 months) Java SE 12 2019 September (6 months) Java SE 13 2020 March (6 months) Java SE 14 2020 September (6 months) Java SE 15 2021 March (6 months) Java SE 16 2021 September (6 months) Java SE 17 (LTS)
  4. OpenJDK Oracle Commercial JDK Oracle OpenJDK Redhat OpenJDK Eclipse Temurin

    Amazon Corretto Azul Zulu Alibaba dragonwell BellSoft Liberica JDK
  5. Oracle JDK and Oracle OpenJDK • Two different builds •

    Oracle OpenJDK (open source) • Can be used free in any environment • Oracle JDK (commercial) • Free for development and testing, in production you will have to pay • Since Java 11: OpenJDK and Oracle JDK are functionally the same. • Differences between support!
  6. Support and Updates • Oracle OpenJDK • Support/Updates only for

    the current version. So if 13 is out, no more updates to 10, 11 or 12. • http://jdk.java.net/13/ • Oracle JDK • You will get support / updates for LTS versions for 3 years • https://www.oracle.com/technetwork/java/javase/downloads/ index.html • Oracle JDK 8 no public updates after Jan 2019 • Oracle JDK 11 extended support for 2026 • Oracle JDK 17 extended support for 2029
  7. SDKMan • SDKMAN! is a tool for managing parallel versions

    of multiple Software Development Kits • Runs on any UNIX based platforms: Mac OSX, Linux, Cygwin, Solaris and FreeBSD. • Works fine with Windows Subsystem for Linux
  8. Usage • List all possibile java installation possibilities • sdk

    list java • Install • sdk install java 17.0.1-tem • List current tools that you use • sdk current • Change java • sdk default java 15.0.2.hs-adpt
  9. You can manage other tools too... sdk current Using: gradle:

    7.0 java: 17.0.1-tem kotlin: 1.6.0 maven: 3.8.4
  10. /Users/<user>/.sdkman/candidates drwxr-xr-x 4 pohjus staff 128 Mar 20 14:06 gradle

    drwxr-xr-x 6 pohjus staff 192 Mar 21 11:18 java drwxr-xr-x 4 pohjus staff 128 Mar 20 13:50 kotlin drwxr-xr-x 4 pohjus staff 128 Mar 21 11:16 maven
  11. /Users/<user>/.sdkman/candidates/java drwxr-xr-x 10 pohjus staff 320 Jan 20 2021 11.0.10.hs-adpt

    drwxr-xr-x 10 pohjus staff 320 Jan 21 2021 15.0.2.hs-adpt drwxr-xr-x 10 pohjus staff 320 Mar 11 2021 16.0.0.hs-adpt drwxr-xr-x 10 pohjus staff 320 Apr 21 2021 16.0.1.hs-adpt drwxr-xr-x 9 pohjus staff 288 Aug 6 04:27 17-open drwxr-xr-x 12 pohjus staff 384 Oct 20 13:04 17.0.1-tem drwxr-xr-x 13 pohjus staff 416 Jan 20 2021 8.0.282.hs-adpt lrwxr-xr-x 1 pohjus staff 10 Dec 13 14:05 current -> 17.0.1-tem
  12. Build Tools • Ant (2000) • One of the first

    "modern" build tools • Very popular among Java • Easy, uses procedural programming idea • Uses XML which is not very good on the concept of procedural programming • XML can began to be very big • Maven (2004) • Uses also XML, but structure is different • Relies conventions and provides available targets (goals) • Has repository support (dependencies) • Gradle (2007) • Uses DSL instead of XML
  13. Maven Project Structure . ├── pom.xml └── src └── main

    └── java └── com └── company └── Main.java xml file, can be complicated!
  14. Gradle Project Structure ├── app │ ├── build.gradle │ └──

    src │ ├── main │ ├── java │ │ └── tuni │ │ └── tamk │ │ └── tiko │ │ └── App.java │ └── resources ├── gradle │ └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle DSL file, either Groovy or Kotlin! Gradle tool is bundled with the project, other developers do NOT need gradle installed on there machines
  15. To build and run • Generate project • gradle init

    • Build • gradle build • Run • gradle run • All available tasks • gradle list
  16. build.gradle plugins { // Apply the application plugin to add

    support for building a CLI application in Java. id 'application' } repositories { // Use JCenter for resolving dependencies. jcenter() } dependencies { // Use JUnit test framework. testImplementation 'junit:junit:4.13' // This dependency is used by the application. implementation 'com.google.guava:guava:29.0-jre' } application { // Define the main class for the application. mainClass = 'myproject.App' } gradle must know which class is the main class Dependencies!
  17. Modification package myproject; import org.apache.commons.io.FileUtils; public class App { public

    static void main(String args[]) throws Exception { FileUtils.getFile("input.txt"); } } Uses external class library!
  18. Modify build.gradle dependencies { // Use JUnit test framework. testImplementation

    'junit:junit:4.13' // This dependency is used by the application. implementation 'com.google.guava:guava:29.0-jre' implementation 'commons-io:commons-io:2.8.0' }