Difference between revisions of "IT-SDK-Java"
Jump to navigation
Jump to search
(→Database) |
Samerhijazi (talk | contribs) (→Releases) |
||
| (61 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| − | = | + | =Ref.= |
| + | * https://dev.java/ | ||
| + | * http://tutorials.jenkov.com/ | ||
* Books: https://www.manning.com/ | * Books: https://www.manning.com/ | ||
* Tutorial: https://www.javatpoint.com/java-tutorial | * Tutorial: https://www.javatpoint.com/java-tutorial | ||
| Line 9: | Line 11: | ||
* https://www.jrebel.com/blog/what-is-jrebel | * https://www.jrebel.com/blog/what-is-jrebel | ||
* Hibernate: http://hibernate.org/ | * Hibernate: http://hibernate.org/ | ||
| + | |||
| + | =Tools= | ||
| + | * https://sdkman.io/ | ||
=Setting= | =Setting= | ||
| − | + | <pre class="text"> | |
* JAVA_HOME=C:\sdk\Java\jdk_1.8.0_65 | * JAVA_HOME=C:\sdk\Java\jdk_1.8.0_65 | ||
| − | * JDK_HOME= | + | * JDK_HOME=%JAVA_HOME% |
| + | * JRE_HOME=%JAVA_HOME% | ||
| + | * ---------------------------------- | ||
| + | * Windows: PATH=%JAVA_HOME%/bin | ||
| + | * Linux: PATH=$PATH:$JAVA_HOME/bin | ||
| + | </pre> | ||
| + | <pre class="text"> | ||
| + | taskkill /f /im jqs.exe | ||
| + | taskkill /f /im javaw.exe | ||
| + | taskkill /f /im java.exe | ||
| + | </pre> | ||
| + | |||
| + | =Installing Java= | ||
| + | *https://www.adoptium.net/ | ||
| + | *https://www.graalvm.org/ | ||
| + | *https://aws.amazon.com/corretto/ | ||
| + | *https://learn.microsoft.com/en-us/java/openjdk/download | ||
| + | ==Releases== | ||
| + | * GA (General-Availability) | ||
| + | * LTS (Long-Term-Support) | ||
| + | * https://en.wikipedia.org/wiki/Java_version_history | ||
| + | <pre class="code"> | ||
| + | * JDK 25 (GA 2025.09.16) LTS <<< | ||
| + | * JDK 24 (GA 2025.03.18) | ||
| + | * JDK 23 (GA 2024.09.17) | ||
| + | * JDK 22 (GA 2024.03.19) | ||
| + | * 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 09 (GA 2017.09.21) | ||
| + | * JDK 08 (GA 2014.03.18) LTS | ||
| + | </pre> | ||
| + | |||
| + | ==Settings== | ||
| + | <pre class="code"> | ||
| + | sudo update-alternatives --config java | ||
| + | sudo update-alternatives --config javac | ||
| + | </pre> | ||
| + | |||
| + | ==fedora== | ||
| + | <pre class="code"> | ||
| + | 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 | ||
| + | </pre> | ||
| + | ==Ubuntu== | ||
| + | <pre class="code"> | ||
| + | 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 | ||
| + | </pre> | ||
| + | ==macOS== | ||
| + | <pre class="code"> | ||
| + | rm -rf /opt/homebrew/opt/openjdk@21 | ||
| + | rm -rf /opt/homebrew/Cellar/openjdk@21 | ||
| + | brew cleanup && brew doctor | ||
| + | ######################################### | ||
| + | brew install openjdk@21 | ||
| + | brew install openjdk@17 | ||
| + | brew install openjdk@11 | ||
| + | brew install --cask corretto | ||
| + | ######################################### | ||
| + | sudo ln -sfn /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdk | ||
| + | echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.zshrc | ||
| + | export CPPFLAGS="-I/opt/homebrew/opt/openjdk@21/include" | ||
| + | ######################################### | ||
| + | brew list --versions openjdk@21 | ||
| + | brew unlink openjdk@21 | ||
| + | brew link --force --overwrite openjdk@21 | ||
| + | </pre> | ||
| + | |||
| + | =Settings= | ||
| + | <pre class="code"> | ||
| + | -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. | ||
| + | </pre> | ||
=Maven= | =Maven= | ||
* ref: https://maven.apache.org/guides/mini/guide-multiple-repositories.html | * ref: https://maven.apache.org/guides/mini/guide-multiple-repositories.html | ||
| + | * ref: https://www.vogella.com/tutorials/ApacheMaven/article.html | ||
<pre class="code"> | <pre class="code"> | ||
wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | ||
| Line 28: | Line 123: | ||
source /etc/profile.d/maven.sh | source /etc/profile.d/maven.sh | ||
mvn -version | mvn -version | ||
| + | </pre> | ||
| + | <pre class="code"> | ||
| + | mvn archetype:generate | ||
| + | -DgroupId=net.samerhijazi | ||
| + | -DartifactId=maven-startup | ||
| + | -DarchetypeArtifactId=maven-archetype-quickstart | ||
| + | -DinteractiveMode=false | ||
| + | </pre> | ||
| + | <pre class="code"> | ||
| + | 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 | ||
</pre> | </pre> | ||
| Line 89: | Line 202: | ||
=Sprin Boot= | =Sprin Boot= | ||
* https://www.baeldung.com/spring-boot-start | * https://www.baeldung.com/spring-boot-start | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:05, 30 September 2025
Contents
Ref.
- https://dev.java/
- http://tutorials.jenkov.com/
- Books: https://www.manning.com/
- Tutorial: https://www.javatpoint.com/java-tutorial
- Tutorial: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/object-oriented-programming
- Tutorial: https://www.tutorialspoint.com/design_pattern/index.htm
- Tutorial: https://howtodoinjava.com/
- Patterns: https://en.wikipedia.org/wiki/Facade_pattern
- Patterns: https://www.baeldung.com/java-core-structural-patterns
- https://www.jrebel.com/blog/what-is-jrebel
- Hibernate: http://hibernate.org/
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
- https://www.adoptium.net/
- https://www.graalvm.org/
- https://aws.amazon.com/corretto/
- https://learn.microsoft.com/en-us/java/openjdk/download
Releases
- GA (General-Availability)
- LTS (Long-Term-Support)
- https://en.wikipedia.org/wiki/Java_version_history
* JDK 25 (GA 2025.09.16) LTS <<< * JDK 24 (GA 2025.03.18) * JDK 23 (GA 2024.09.17) * JDK 22 (GA 2024.03.19) * 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 09 (GA 2017.09.21) * 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
rm -rf /opt/homebrew/opt/openjdk@21 rm -rf /opt/homebrew/Cellar/openjdk@21 brew cleanup && brew doctor ######################################### brew install openjdk@21 brew install openjdk@17 brew install openjdk@11 brew install --cask corretto ######################################### sudo ln -sfn /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdk echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.zshrc export CPPFLAGS="-I/opt/homebrew/opt/openjdk@21/include" ######################################### brew list --versions openjdk@21 brew unlink openjdk@21 brew link --force --overwrite openjdk@21
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
- ref: https://maven.apache.org/guides/mini/guide-multiple-repositories.html
- ref: https://www.vogella.com/tutorials/ApacheMaven/article.html
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.
- JDBC: https://quarkus.io/guides/datasource
- Reactive: https://quarkus.io/guides/reactive-sql-clients
- Oracle: https://blogs.oracle.com/developers/configuring-the-oracle-jdbc-drivers-with-quarkus
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.
- https://quarkus.io/guides/rest-json
- https://quarkus.io/guides/rest-client
- https://quarkus.io/guides/resteasy-reactive
- https://lankydan.dev/building-a-rest-api-with-quarkus
- https://dzone.com/articles/building-a-rest-api-with-quarkus