Maven & architecture - how to build all available architectures? - maven

I'm actually trying to compile some native code, but that I think that has to wait for a moment. Please consider the following as building up to resolving Native builds with Maven-NAR-pluggin.
We have 64 bit windows machines currently which are quite capable of also compiling 32 bit software. (yes I know, still waiting for the 128 bit)
How do we configure Maven pluggins / POM to compile both?
aka override the architecture as provided from the JRE that was found in JAVA_HOME
C:\Data\dev\zlib\minizip>mvn -X compile
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_31
Java home: C:\Program Files\Java\jdk1.6.0_31\jre
Default locale: en_AU, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
c:\Data\dev\zlib\miniunzip>mvn -X compile
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_20
Java home: C:\Program Files (x86)\Java\jdk1.6.0_20\jre
Default locale: en_AU, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"
We may also have a need to compile some modules to different JRE versions due to being a loaded library used in JRE 1.3/1.4/1.5/1.6
Is it possible to configure Maven POM to have profile differences or build differences based on the JRE version we are compiling to, or do we have to have 4 POM?
Is it possible to configure Maven to Run tests using an alternate JRE to that executing the Maven build?

Related

maven ignores maven.compiler.source

I have
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
in my pom.xml.
If I run mvn clean install then I can't run the compiled classes with Java 1.8 (I get crashes with errors like java.lang.NoClassDefFoundError: Could not initialize class when I try to).
I am forced to run
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home mvn clean install
if I want it to be able to run the built jar with java 8 without crashes.
How can I make it actually use the correct JDK that I want?
Here is how my machine seems to be set up by default
$ mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T19:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 11.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.2", arch: "x86_64", family: "mac"
$ java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
$ echo $JAVA_HOME
$

Maven for Ubuntu ARM64

I have a Jetson Tx2 which is Ubuntu Linux ARM64. I can't seem to find a 'binary' distribution for this. Is my only option to get the source for Maven 3.3.9, build that and then build Maven 3.5 using the 3.3.9 version?
My ultimate goal is to get apache pulsar installed on this same platform.
Thanks,
Mike
Maven is distributed with native Jansi support in the form of dynamic link libraries for Freebsd 32/64, Linux 32/64. Windows 32/64 and Osx. This is the only dependency to native code I am aware of.
That is, you don't need to build Maven, you just have to download a 'binary' archive such as this one, and to extract it - I am assuming here you already have a JDK for Aarch64 Linux installed.

kotlin compiler issues for unresolved class

Kotlin compiler has some confusing error messaging for unresolved classes. One developer's project compiles, and the other developers does not. They have the same code. Here is the error...
[ERROR] Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class java.lang.AutoClosable, unresolved supertypes: Object
class com.mycompany.ProviderObjIdentity, unresolved supertypes: Object
I don't know where to start debugging this problem. There are no differences in the code for the projects, but I guess the two developers are using different JDKs. Maybe different versions of maven. Definitely different flavors of linux.
I'd be happy to provide any additional information, I just don't know what would be helpful.
this dev guy's setup is busted:
Kotlin: 1.0.4
sles SUSE Linux Enterprise Server 11 (x86_64)
Linux 3.0.76-0.11-default
mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 06:51:28-0700)
Maven home: /home/devguy1/apache-maven-3.0.5
Java version: 1.7.0, vendor: IBM Corporation
Java home: /usr/lib64/jvm/java-1.7.0-ibm-1.7.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.0.76-0.11-default", arch: "amd64", family: "unix"
It looks like Kotlin's issue with IBM J9 JVM implementation reported as KT-14437 in the JB issue tracker. The fix is in work and most likely will be included in some upcoming Kotlin release. Meanwhile, you may want to use Oracle JDK as a workaround.

Error: JAVA_HOME is not defined correctly, when installing Maven on Mac

It is suppose to be easy, but I'm having great difficulty installing Maven on to my mac 10.11.4.
I have created M2_HOME and PATH for Maven, but when I type in mvn --version, the terminal tell me
/Users/justin/apache-maven-3.3.9/bin/mvn: line 53: uname: command not found
/Users/justin/apache-maven-3.3.9/bin/mvn: line 143: which: command not found
/Users/justin/apache-maven-3.3.9/bin/mvn: line 171: which: command not found
Error: JAVA_HOME is not defined correctly.
We cannot execute
Why is this happening?
You need JAVA_HOME to be defined, as covered in installation guide.
Check out this answer for additional details for MacOS.
For macOs Ventura 13.1
If you installed java openJdk version 11 using Homebrew:
brew install java11
Then, your java is installed on:
/opt/homebrew/Cellar/openjdk#11/11.0.17/libexec/openjdk.jdk/Contents/Home
So, you must understand that this is you JAVA_HOME environment variable.
You need to add the java '/bin' folder to your PATH environment variable in order to have it working on your terminal. Also, you need to create the JAVA_HOME environment variable in order to maven to know about your java.
Therefore, you must open:
/Users/<yourUser>/.zshrc
Add
export JAVA_HOME="/opt/homebrew/Cellar/openjdk#11/11.0.17/libexec/openjdk.jdk/Contents/Home"
export PATH="/opt/homebrew/opt/openjdk#11/bin:$PATH"
Save your changes, close the file. Now you can open your terminal and type:
java -version
and then,
mvn -version
and this is what you should get:
example#example441 ~ % java -version
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment Homebrew (build 11.0.17+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.17+0, mixed mode)
example#example441 ~ % mvn -version
Apache Maven 3.8.7 (xxxxxxxxxxxxxxxxxxxxxxxxxxx)
Maven home: /opt/homebrew/Cellar/maven/3.8.7/libexec
Java version: 11.0.17, vendor: Homebrew, runtime:
opt/homebrew/Cellar/openjdk#11/11.0.17/libexec/openjdk.jdk/Contents/Home
Default locale: pt_BR, platform encoding: UTF-8
OS name: "mac os x", version: "13.1", arch: "aarch64", family: "mac"

Location of jfxrt.jar on Mac OS X

I'm trying to compile/run some JavaFX code.
On my PC I reference: C:/Program Files/Oracle/JavaFX 2.1 SDK/rt/lib/jfxrt.jar
My understanding is that JavaFX is included in JDK 7 on Mac OS x but I cannot find jfxrt.jar in:
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/
Edit (Nov 2019): Currently OpenJDK doesn't include OpenJFX. Some OpenJDK providers include OpenJFX into their installation. For the rest, you can use maven or gradle to include it into your projects.
Java7: jre/lib/jfxrt.jar
Java8: jre/lib/ext/jfxrt.jar
you can find it using find $JAVA_HOME -name jfxrt.jar
Since Java9 there is no jfxrt.jar, it's now a set of modules:
./jmods/javafx.base.jmod
./jmods/javafx.media.jmod
./jmods/javafx.swing.jmod
./jmods/javafx.controls.jmod
./jmods/javafx.web.jmod
./jmods/javafx.fxml.jmod
./jmods/javafx.graphics.jmod

Resources