I have created a java application that uses the Selenium library for web scraping. The application works in the IDE (eclipse). Now I want to create a mac bundle using java packager. But the java packager produces and error:
Exception: java.lang.Exception: Error: Modules are not allowed in srcfiles: [../Released/run.jar].
Error: Bundler "Mac Application Image" (mac.app) failed to produce a bundle.
The script that runs the java packager looks like this:
#!/bin/bash
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home"
export PATH=$JAVA_HOME/bin:$PATH
./jpackager \
create-image \
-i ../Released \
-o ../Released \
-n "MyWineApp" \
-c mywineapp.gui.MyWineApp \
-j run.jar \
-v "1.0.0" \
--icon ../Images/wine.icns \
--add-modules java.base,java.desktop \
--jvm-args '--add-opens javafx.base/com.sun.javafx.reflect=ALL-UNNAMED'
I have used this script before successfully. The difference with this project is that this projects uses the Selenium library. What is the right way to use java packager in this case?
Related
I'm creating a Kotlin compose app and I want to create a distributable package for Mac OS using jpackage (I know about the packageDmg Gradle task, but now I want to go around it).
The jar file works fine but the installed app crashes on start. By running the app from terminal (open /Applications/MyApp/Contents/MacOS/myapp) I found out that it throws this exception java.lang.NoClassDefFoundError: javax/swing/SwingUtilities
I've included all modules that the suggestRuntimeModules task suggested but it does not include anything that seems swing related to me.
I'm on an M1 mac with and java --version gives me this java 15.0.2 2021-01-19
Here is my packaging command:
jpackage --input ./ \
--name myApp \
--main-jar myapp-macos-x64-1.1.3.jar \
--type pkg \
--icon ../../../src/main/resources/icon.icns \
--app-version '1.1.3' \
--mac-package-name "My App" \
--vendor "My App" \
--add-modules java.instrument,java.net.http,java.prefs,java.sql,jdk.unsupported
I'm using OpenJDK 18.0.1.1 with jlink and jpackage to create apps with a bundled JRE from our application. I'm using a new Macbook with M1 processor and I'm calling:
jpackage create-app-image \
-o "/Workspace/" \
-i /Workspace/installer \
-n MyAppName \
--runtime-image $RUNTIMEJDK/myruntime \
--main-class company.myapp.mainclass \
--main-jar mainclass.jar \
--icon /Workspace/icons/MyAppName.icns \
--vendor "myCompany" \
--description "This is my application"
When I call
lipo -info /Workspace/MyAppName.app/Contents/MacOS/MyAppName
the architecture is x86_64. My OpenJDK is arm64.
How can I tell jpackage to create an arm64 app?
Has anyone come across this error when trying to execute a docker-compose up command.
I have tried to resolve it by looking at other articles that touch on something similar but I am having no success.
I am trying to run my spring boot app using a docker-compose file and I keep getting this error:
qemu-x86_64: Could not open '/lib/ld-musl-x86_64.so.1': No such file or directory
I have tried to fix it by following the advice I read online but nothing has worked.
I have tried:
After reading this post: https://github.com/nodejs/help/issues/3239
adding the following
platform: linux/amd64
to my docker-compose file but it doesn't make a difference
and tried FROM --platform=linux/amd64 in front of my Dockerfile
When I read this I tried to install musl as well but failed to execute the make command
curl https://musl.libc.org/releases/musl-1.2.2.tar.gz -o musl-1.2.2.tar.gz
tar -xvf musl-1.2.2.tar.gz
cd musl-1.2.2
./configure
make
make install
My Docker file looks like this
FROM azul/zulu-openjdk-alpine:11 as packager
RUN { \
java --version ; \
echo "jlink version:" && \
jlink --version ; \
}
ENV JAVA_MINIMAL=/opt/jre
# build modules distribution
RUN jlink \
--verbose \
--add-modules \
java.base,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument \
# java.naming - javax/naming/NamingException
# java.desktop - java/beans/PropertyEditorSupport
# java.management - javax/management/MBeanServer
# java.security.jgss - org/ietf/jgss/GSSException
# java.instrument - java/lang/instrument/IllegalClassFormatException
--compress 2 \
--strip-debug \
--no-header-files \
--no-man-pages \
--output "$JAVA_MINIMAL"
# Second stage, add only our minimal "JRE" distr and our app
FROM alpine
ENV JAVA_MINIMAL=/opt/jre
ENV PATH="$PATH:$JAVA_MINIMAL/bin"
COPY --from=packager "$JAVA_MINIMAL" "$JAVA_MINIMAL"
COPY "build/libs/company-coordinator-app-0.0.1-SNAPSHOT.jar" "/company-coordinator-app.jar"
EXPOSE 8080
CMD [ "-jar", "/company-coordinator-app.jar" ]
ENTRYPOINT [ "java" ]
and my docker-compose.yml file looks like this
version: '2'
services:
company-coordinator-app:
container_name: 'company-coordinator-app'
build:
context: /Users/ciaran/cmkdev/company-coordinator-project/company-coordinator-app
dockerfile: Dockerfile
image: springio/gs-spring-boot-docker
ports:
- "8080:8080"
I am running this off an M1 mbp
I read this post on here in an attempt to build my Dockerfile correctly as I needed to use Java 11.
Java 11 application as lightweight docker image
If anyone has any insights here it would be greatly appreciated.
It seems azul/zulu-openjdk-alpine:11 doesn't have arm64 image needed to run on Apple silicon architecture.
Try updating to jdk 17 image with arm64 support https://hub.docker.com/r/azul/zulu-openjdk-alpine/
I am using Java 13 preview features, but I can't find the option in jlink to add the "--enable-preview" flag to the java command inside of the launcher script jlink generates.
As you can see, the launcher script that is generated is
#!/bin/sh
JLINK_VM_OPTIONS=
DIR=`dirname $0`
$DIR/java $JLINK_VM_OPTIONS -m wla_server/net.saga.snes.dev.wlalanguageserver.Main $#
However, I don't know how to get the script to be generated with JLINK_VM_OPTIONS=--enable-preview using the jlink command.
My jlink command is
$JAVA_HOME/bin/jlink \
--module-path target/classes:target/dependency \
--add-modules ALL-MODULE-PATH \
--launcher launcher=wla_server/net.saga.snes.dev.wlalanguageserver.Main \
--output dist/linux \
--vm=server \
--compress 2
I've added the following sed command to my build script :
sed -i 's/JLINK_VM_OPTIONS=.*/JLINK_VM_OPTIONS=--enable-preview/' dist/linux/bin/launcher
This edits the launcher script:
#!/bin/sh
JLINK_VM_OPTIONS=--enable-preview
DIR=`dirname $0`
$DIR/java $JLINK_VM_OPTIONS -m wla_server/net.saga.snes.dev.wlalanguageserver.Main $#
Which works well enough.
I need to run my Java application on Mac. I could find this tutorial to use Xcode to bundle the application. The tutorial asks readers to have access to Jar Bundle application butI could not find it in the /Developer/Applications/Java Tools/ folder.
After that I came across this answer which seems is offering a good method to do it.
However, I am wondering if there is any better way to get the job done rather than the one mentioned there.
The Mac OS X utilities Jar Bundler, Icon Composer, and PacakgeMaker are all deprecated. Even the various AppBundler projects out there seem destine to fade away.
The way forward looks to be javapackager, which is included in the JDK.
The -deploy -native pkg options will convert a Java application (Executable JAR) into a native macOS installer.
Example commands:
$ jar cmf MainClass.txt ShowTime.jar *.class
$ javapackager -deploy -native pkg -srcfiles ShowTime.jar \
-appclass ShowTime -name ShowTime \
-outdir deploy -outfile ShowTime -v
Output: deploy/bundles/ShowTime-1.0.pkg
I posted a detailed tutorial at: centerkey.com/mac/java
For better or worse, javapackager bundles the JRE and the resulting .pkg file is over 60MB.
As Dem says, I user javapackager like this:
Open terminal and go to working folder like cd Desktop/
and type;
javapackager \
> -deploy \
> -title AppTitle \
> -name AppName \
> -appclass your.app.class \
> -native dmg \
> -outdir ~/YourOutputDir \
> -outfile out \
> -srcfiles your.jar