Difference between revisions of "IT-SDK-Java"

From wiki.samerhijazi.net
Jump to navigation Jump to search
(Setting)
(LTS-Releases)
Line 33: Line 33:
 
*https://adoptium.net/
 
*https://adoptium.net/
 
*https://www.graalvm.org/
 
*https://www.graalvm.org/
==LTS-Releases==
+
==Releases: GA (General Availability) & LTS (Long-Term-Support) ==
* >>> Java Version 21 Long-Term-Support (LTS), released on 2023 September, tbd
+
* JDK 22 (in development)
* Java Version 17 Long-Term-Support (LTS), released on 2021 September, 14th
+
* '''JDK 21''' (GA 2023/09/19) ==> LTS
* Java Version 11 Long-Term-Support (LTS), released on 2018 September, 25th
+
* JDK 20 (GA 2023/03/21)
* Java Version 08 Long-Term-Support (LTS), released on 2014 March, 18th
+
* JDK 19 (GA 2022/09/20)
 +
* JDK 18 (GA 2022/03/22)
 +
* '''JDK 17''' (GA 2021/09/14) ==> LTS
 +
* JDK 16 (GA 2021/03/16)
 +
* JDK 15 (GA 2020/09/15)
 +
* JDK 14 (GA 2020/03/17)
 +
* JDK 13 (GA 2019/09/17)
 +
* JDK 12 (GA 2019/03/19)
 +
* '''JDK 11''' (GA 2018/09/25) ==> LTS
 +
* JDK 10 (GA 2018/03/20)
 +
* '''JDK 08''' (GA 2014/03/18) ==> LTS
  
 
==Settings==
 
==Settings==

Revision as of 12:26, 28 November 2023

Ref.

Tools

Setting

* JAVA_HOME=C:\sdk\Java\jdk_1.8.0_65
* JDK_HOME=%JAVA_HOME%
* JRE_HOME=%JAVA_HOME%
* ----------------------------------
* Windows: PATH=%JAVA_HOME%/bin
* Linux: PATH=$PATH:$JAVA_HOME/bin
taskkill /f /im jqs.exe
taskkill /f /im javaw.exe
taskkill /f /im java.exe

Installing Java

Releases: GA (General Availability) & LTS (Long-Term-Support)

  • JDK 22 (in development)
  • JDK 21 (GA 2023/09/19) ==> LTS
  • JDK 20 (GA 2023/03/21)
  • JDK 19 (GA 2022/09/20)
  • JDK 18 (GA 2022/03/22)
  • JDK 17 (GA 2021/09/14) ==> LTS
  • JDK 16 (GA 2021/03/16)
  • JDK 15 (GA 2020/09/15)
  • JDK 14 (GA 2020/03/17)
  • JDK 13 (GA 2019/09/17)
  • JDK 12 (GA 2019/03/19)
  • JDK 11 (GA 2018/09/25) ==> LTS
  • JDK 10 (GA 2018/03/20)
  • JDK 08 (GA 2014/03/18) ==> LTS

Settings

sudo update-alternatives --config java
sudo update-alternatives --config javac

fedora

sudo dnf install java-17-openjdk-devel       ## JDK
sudo dnf install java-17-openjdk-headless    ## JRE-Min
sudo dnf install java-17-openjdk             ## JRE-Full

Ubuntu

sudo apt install default-jre      ### JRE
sudo apt install default-jdk      ### JDK
----
sudo apt install openjdk-17-jre   ### JRE
sudo apt install openjdk-17-jdk   ### JDK

macOS

brew install openjdk@20
brew install openjdk@17
brew install openjdk@11

Settings

-Xms1g                   ### Setting the initial and minimum heap size for 1G.
-Xmx1g                   ### Setting the maximum heap size for 1G.
-XX:+PrintGCDetails      ### Detaillierte GC Logging.
-XX:+PrintGCDateStamps   ### Jeder Zeile eine absolute Datums- und Zeitangabe vorangestellt.
-Xloggc:file.log         ### Das GC Log wird in der Datei <file.log> geschrieben.

Maven

wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
sudo tar xzf apache-maven-3.6.3-bin.tar.gz
sudo ln -s apache-maven-3.6.3 maven
sudo vi /etc/profile.d/maven.sh
-------------------------------------
export MAVEN_HOME=/opt/maven
export PATH=${MAVEN_HOME}/bin:${PATH}
-------------------------------------
source /etc/profile.d/maven.sh
mvn -version
mvn archetype:generate 
-DgroupId=net.samerhijazi 
-DartifactId=maven-startup 
-DarchetypeArtifactId=maven-archetype-quickstart 
-DinteractiveMode=false
mvn clean
mvn compile
mvn package
mvn dependency:list-repositories
mvn dependency:tree
mvn dependency:analyze
mvn dependency:copy-dependencies
mvn dependency:get -Dartifact=com.google.protobuf:protobuf-java:3.19.1
mvn dependency:get -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0

Code-Collections

import java.util.concurrent.TimeUnit;
---------------------------------------------
try {
    TimeUnit.SECONDS.sleep(secondsToSleep);
} catch (InterruptedException ie) {
    Thread.currentThread().interrupt();
}
---------------------------------------------
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import io.agroal.api.AgroalDataSource;

public class SettingDatabase{

  AgroalDataSource dataSource;
  String db = "jdbc:db2://localhost:5245/DATABASE:user=db2;password=db2;";
  String sql = "SELECT * FROM users";

  public void init_DriverManager()throws SQLException{
    try{		
      Connection connection = DriverManager.getConnection(db); //Connection connection = AgroalDataSource.getConnection(db);
      PreparedStatement ps = connection.prepareStatement(sql);
      ResultSet rs = ps.executeQuery();
    }
  }	
}

Architekture

Database

  • JDBC is a low level standard for interaction with databases. JPA is higher level standard for the same purpose.
  • JDBC allows you to do more things with the Database directly. JPA allows you to use an object model in your application.
  • Datasource & Pooling (JDBC) >> Agroal
  • Datasource & Pooling (Reactive) >> Vert.x
  • Agroal is a datasource connection pool implementation with integration with transaction, security and other systems.
  • Agroal library allows the definition of java.sql.DataSource with connection pooling.
  • JPA (Java Persistence API) & Hibernate ORM (Object-relational mapping). JPA is only a specification. Hibernate is an implementation of JPA.

RESTFul

  • RESTEasy is an implementation of JAX-RS and it is used to implement RestFul-services.
  • Microservices communicating either synchronously via REST or asynchronously using Kafka.

Sprin Boot