Maven
With Maven, you can have better dependency management.
sudo apt-get update
sudo apt-get -y install maven
mvn -v
# Apache Maven 3.8.2
# To install on Windows download maven binary zip from apache website.
# Add /bin folder to your path and test maven installation.
Pom
Create Maven pom.xml project definition (next to src folder).
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.minte9</groupId>
<artifactId>demoJodaTime</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.minte9.demo.DemoCurrentTime</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Compile
Compile and run the project.
cd D:\developments\myproject
mvn package
# mvn clean
# mvn install
# mvn compile
java -jar ./target/demo-maven-0.1.0.jar
# The current local time is: 16:57:00.610
M2
The .m2 repository is located in your home directory.
/home/catalin/.m2
# C:\Users\Catalin\.m2\repository
Windows
Extract to directory and add to PATH environment.
PATH D:\apache-maven-3.8.4\bin
Version: mvn --version
# Apache Maven 3.8.4
Settings
D:\apache-maven-3.8.4\conf\settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0
http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<mirrors>
<mirror>
<id>Artifactory</id>
<name>Artifactory Public Mirror</name>
<url>
https://artifacts.myapps.com:443/artifactory/maven-central-remote/
</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
Certificate
Se Environment PATH generate and import certificate.
D:\openssl-1.1.1k-vs16-x86\bin
D:\>openssl version
OpenSSL 1.1.1k
cd D:\apache-maven-3.8.4
openssl s_client -showcerts -connect artifacts.myapps.com:443 |
openssl x509 -outform PEM > artifacts_ca.cer
echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.8.0_281
keytool -import -trustcacerts -keystore
"%JAVA_HOME%\jre\lib\security\cacerts" -storepass
myappspassword -alias Artifact -import -file artifacts_ca.cer
# important: JAVA_HOME\jre
mvn -version
Apache Maven 3.8.4
Maven home: D:\apache-maven-3.8.4
Java version: 1.8.0_281, runtime: jdk1.8.0_281\jre
Project
cd D:\maven\demo
mvn package
D:\maven\demo>java -jar target\demo-maven-0.1.0.jar
The current local time is: 12:04:45.864
Last update: 432 days ago