I am copying the working version of the JRE directory into docker and trying to run /JRE/bin/java.
But it throws ash: java not found error. I am doing the same in a linux VM . Just copying the JRE folder and executing java command which works fine in VM. I don't want to download JRE from anywhere.
Want this specific JRE bundled.How to resolve this.
I entered into the shell console and navigated to the JRE/bin/ directory and executed "java". even then it fails . The error is same ash: java not found error.
Dockerfile:
FROM alpine:latest
ENV HOME=/root \
DEBIAN_FRONTEND=noninteractive \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=C.UTF-8 \
DISPLAY=:0.0 \
DISPLAY_WIDTH=1024 \
DISPLAY_HEIGHT=768
RUN apk --update --upgrade add \
bash \
fluxbox \
x11vnc \
xterm \
xvfb
COPY MyJavaApp MyJavaApp/
WORKDIR /MyJavaApp
ENV PATH="./JRE/bin:${PATH}"
When are you copying the JRE directory to the docker? i.e Docker build time or after spinning up the Docker container?
Looks like you are correctly copying the local Java directory to the image, however the current location cannot access the java binaries, thus, make sure to set the PATH. It should be something like,
RUN export PATH=/JRE/bin:${PATH}
or pass the path to the ENV in the Dockerfile,
ENV PATH="/JRE/bin:${PATH}"
Related
I'm fairly new to Docker and am struggling with JAVA_HOME not being seen in a Dockerfile. I get the titular error; which includes Please set the JAVA_HOME variable in your environment to match the location of your Java installation. & executor failed running [/bin/sh -c /opt/Android/cmdline-tools/latest/bin/sdkmanager --update]: exit code: 1 when it runs RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --update.
I feel like I'm at a loss but I think my issue is not knowing where the JDK is being installed to or knowing how to find it from a Dockerfile; I've tried echoing JAVA_HOME thinking I could see it while the image built but, again, no luck. Any help with this would be greatly appreciated. I've been pulling my hair out Googling & trying things. Thank you.
FROM node:12.12.0
ARG CMDLINE_TOOLS_VERSION=7583922
ARG ANDROID_BUILD_TOOLS=30.0.3
RUN apt-get -qqy update \
&& apt-get -qqy install \
python-dev \
--no-install-recommends
RUN apt-get install -y software-properties-common gcc
RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install awscli
RUN apt-get install -y jq
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2
RUN apt-get update && apt-get install -y --no-install-recommends openjdk-8-jdk && apt-get clean;
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV PATH=$PATH:$JAVA_HOME/bin
RUN wget -q https://services.gradle.org/distributions/gradle-4.5.1-bin.zip && unzip gradle-4.5.1-bin.zip -d /opt && rm gradle-4.5.1-bin.zip
ENV GRADLE_HOME=/opt/gradle-4.5.1
ENV PATH=$PATH:/opt/gradle-4.5.1/bin
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_TOOLS_VERSION}_latest.zip
RUN mkdir -p /opt/Android/cmdline-tools
RUN unzip commandlinetools-linux-7583922_latest.zip -d /opt/Android/cmdline-tools
RUN mv /opt/Android/cmdline-tools/cmdline-tools /opt/Android/cmdline-tools/latest
ENV ANDROID_HOME=/opt/Android
ENV PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin \
:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --update
RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --list
RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --list | grep build-tools
RUN echo y | /opt/Android/cmdline-tools/latest/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" "platform-tools" "platforms;android-30" "tools" >/dev/null
RUN yes | /opt/Android/cmdline-tools/latest/bin/sdkmanager --licenses
CMD ["yarn", "start"]
I'd suggest to use another base image. Java 11 is required to build for newer API levels:
FROM openjdk:11-jdk as builder
...
And then install Python3 and AWS CLI.
Working example: cloudbuild-android.
Or if you want to continue with your's, RUN which java would tell you where it's actually installed.
In a comment, you mentioned:
when I run [RUN ls -lart /usr/lib/jvm/java-8-openjdk-amd64], I get cannot access '/usr/lib/jvm/java-8-openjdk-amd64': No such file or directory
Maybe I'm missing something, but... doesn't that mean that the directory does not exist?
Either you got the path wrong, or (as another answer suggested) there's something in your Dockerfile, probably line endings, that's mangling your lines.
To discard the bit about line endings, try the same command but switching the parameters, i.e.:
RUN ls /usr/lib/jvm/java-8-openjdk-amd64 -lart
If now it whines about unrecognized options, then it's probably a line ending issue (which now affects the t option instead of the directory path).
However, if it still says No such file or directory, then you definitely should check your Java installation path.
I think your problem is in the line termination characters of your Dockerfile.
Your Dockerfile works in my computer, and when it comes to weird errors, I have been there.
My experience with Dockerfiles is that sometimes they are very picky in the Windows/Unix/Mac line terminators, so please make sure you save the Dockerfile with line terminators adequate for Unix machines.
I have used the method in this other answer to successfully replace Windows line terminators for Unix's on Windows using Powershell. I hope this helps!
The exact location of $JAVA_HOME can be scripted. If you don't feel like hardcoding that directory is a safe bet, replace your ENV line with this RUN: RUN export JAVA_HOME=$(readlink -f $(which java) | sed "s:/bin/java::"). This is how I set up my environment in all my Linux machines, and what it does is the following:
which java searches for java and will output /usr/bin/java, or something like that, which is a symbolic link.
readlink -f over the above will get you to the destination of the symbolic link.
piping such destination over to | sed "s:/bin/java::" will strip the trailing bin/java and get you the right value, no matter the version.
I also tried your Dockerfile with this change, and it does work too.
It looks like you had some network issues during your first docker build run. It failed to install java, but cached the layer with the attempt. I recommend you to run your build again without caching: docker build -t name --no-cache . and check logging of network operations.
The docker image definition below does not contain according to the documentation a SQL Server driver.
How can I install it?
Documentation:
https://github.com/camunda/docker-camunda-bpm-platform
Docker File
FROM alpine:3.10 as builder
ARG VERSION=7.12.0
ARG DISTRO=tomcat
ARG SNAPSHOT=true
ARG EE=false
ARG USER
ARG PASSWORD
RUN apk add --no-cache \
ca-certificates \
maven \
tar \
wget \
xmlstarlet
COPY settings.xml download.sh camunda-tomcat.sh camunda-wildfly.sh /tmp/
RUN /tmp/download.sh
##### FINAL IMAGE #####
FROM alpine:3.10
ARG VERSION=7.12.0
ENV CAMUNDA_VERSION=${VERSION}
ENV DB_DRIVER=org.h2.Driver
ENV DB_URL=jdbc:h2:./camunda-h2-dbs/process-engine;MVCC=TRUE;TRACE_LEVEL_FILE=0;DB_CLOSE_ON_EXIT=FALSE
ENV DB_USERNAME=sa
ENV DB_PASSWORD=
ENV DB_CONN_MAXACTIVE=20
ENV DB_CONN_MINIDLE=5
ENV DB_CONN_MAXIDLE=20
ENV DB_VALIDATE_ON_BORROW=false
ENV DB_VALIDATION_QUERY="SELECT 1"
ENV SKIP_DB_CONFIG=
ENV WAIT_FOR=
ENV WAIT_FOR_TIMEOUT=30
ENV TZ=UTC
ENV DEBUG=false
ENV JAVA_OPTS="-Xmx768m -XX:MaxMetaspaceSize=256m"
EXPOSE 8080 8000
# Downgrading wait-for-it is necessary until this PR is merged
# https://github.com/vishnubob/wait-for-it/pull/68
RUN apk add --no-cache \
bash \
ca-certificates \
openjdk11-jre-headless \
tzdata \
tini \
xmlstarlet \
&& wget -O /usr/local/bin/wait-for-it.sh \
"https://raw.githubusercontent.com/vishnubob/wait-for-it/a454892f3c2ebbc22bd15e446415b8fcb7c1cfa4/wait-for-it.sh" \
&& chmod +x /usr/local/bin/wait-for-it.sh
RUN addgroup -g 1000 -S camunda && \
adduser -u 1000 -S camunda -G camunda -h /camunda -s /bin/bash -D camunda
WORKDIR /camunda
USER camunda
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./camunda.sh"]
COPY --chown=camunda:camunda --from=builder /camunda .
I was able to make it work after several days.
Steps
Download JDBC Driver from Microsoft Site, Version 7.2, it will include 2 JAR FILES
Uncompress, and copy the file into your docker folder
Copy the file into the camunda LIB folder, this is not explained anywhere, but after a short chat with camunda docker git repo people, they adviced me to do that.
Only line needs to add in DOCKER file is:
#MSSQL SERVER JDBC DRIVER INSTALL
COPY mssql-jdbc-7.2.2.jre11.jar /camunda/lib/
According to the documentation you refer to, Microsoft SQL Server is not supported.
So while you could try some exercise of downloading the JDBC driver (https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-2017) and then add it to the Docker image and the classpath:
COPY name_of_jdbc_driver.jar /camunda/mssqlserver.jdbc
env CLASSPATH=/camunda/mssqlserver.jdbc
It's more than likely that this won't work because the camunda software does not support MS SQL Server.
So you should consider simply using one of the other databases that they explicitly support. I'd recommend PostgreSQL for example. It's free (as in beer and speech) and you can use it in production if you want to.
If you're just looking to do some testing and don't need this in a production environment. The instructions you point to have a decent explanation on how to start PostgreSQL in a Docker container and then start the Camunda container that uses the PostgreSQL container as a database.
All,
Attempting to install liquibase on Heroku so that we can update our database as part of our NodeJs deployments but running into (I'm guessing) classpath errors.
app structure
bower_components
liquibase
- install
- update
node_modules
src
package.json
...
Heroku can run a postinstall script where we run the liquibase install
package.json
"scripts": {
"postinstall": "./liquibase/install && ./liquibase/update && ./node_modules/bower/bin/bower install && ./node_modules/grunt-cli/bin/grunt bundle --force",
}
liquibase install script. Downloads the postgresql.jar and the liquibase executable and puts them in the liquibase folder.
#!/usr/bin/env bash
wget https://github.com/liquibase/liquibase/releases/download/liquibase-parent-3.5.3/liquibase-3.5.3-bin.tar.gz
mkdir -p ~/liquibase
tar -zx -C ~/liquibase -f liquibase-3.5.3-bin.tar.gz
wget https://jdbc.postgresql.org/download/postgresql-42.1.1.jar
mkdir -p ~/lib
mv postgresql-42.1.1.jar ~/lib/postgresql.jar
After the install, we attempt to run the liquibase update (./liquibase/update)
liquibase \
--logLevel="info" \
--driver="org.postgresql.Driver" \
--classpath="$~/lib/postgresql.jar" \
--changeLogFile="liquibase.xml" \
--url="jdbc:postgresql://$HOST:$PORT/$DATABASE" \
--username="$USERNAME" \
--password="$PASSWORD" \
update
But I get the error
liquibase: command not found
That makes me think liquibase isn't on the path
So I do this
export PATH=${PATH}:~/liquibase
Which gives me this error
Error: Could not find or load main class null
Yay for Java :( So no Java or classpath isn't set?
java -v
java version "1.7.0_151"
OpenJDK Runtime Environment (IcedTea 2.6.11) (7u151-2.6.11-0ubuntu1.14.04.1)
OpenJDK 64-Bit Server VM (build 24.151-b01, mixed mode)
echo $JAVA_HOMENothing
which java/usr/bin/java
Maybe I should set $JAVA_HOME=/usr/bin/java
Again, nothing.
At this point, I've got no clue on how to proceed. Any help would be appreciated.
* SOLVED *
Adding the buildpack helped. Also needed to modify the update script
HOME=~
java -jar $HOME/liquibase/liquibase.jar \
--logLevel="info" \
--driver="org.postgresql.Driver" \
--classpath="$HOME/lib/postgresql.jar" \
--changeLogFile="liquibase.xml" \
--url="jdbc:postgresql://$HOST:$PORT/$DATABASE" \
--username="$USERNAME" \
--password="$PASSWORD" \
update
and then the postinstall script
"scripts": {
"postinstall": "cd liquibase && ./install && ./update && cd .. && ./node_modules/bower/bin/bower install && ./node_modules/grunt-cli/bin/grunt bundle --force"
}
First, you'll want to add the JVM buildpack to your app:
$ heroku buildpacks:add -i 1 heroku/jvm
This will install JDK 8 (instead of the default JDK 7), set JAVA_HOME correctly, and even set JDBC_DATABASE_URL (which you can use directly in your --url option).
The message "Error: Could not find or load main class null" suggests that the java command created by the liquibase script (the one you are running) is either malformed, or incomplete. I think this may be due to the option --classpath="$~/lib/postgresql.jar", which looks odd. Or the location of the liquibase.jar relative to the script.
I think you want your classpath option to look like:
--classpath="/app/path/to/classes:/app/lib/postgresql.jar"
If you still have trouble, I would try running the liquibase.jar directly instead of using the script, like:
java -jar liquibase.jar \
--logLevel="info" \
--driver="org.postgresql.Driver" \
--classpath="/app/path/to/classes:/app/lib/postgresql.jar" \
--changeLogFile="liquibase.xml" \
--url="$JDBC_DATABASE_URL" \
--username="$JDBC_DATABASE_USERNAME" \
--password="$JDBC_DATABASE_PASSWORD" \
update
I have properly installed jdk in my system, I have also set the CLASSPATH properly, but when I am installing ArgoUML, it shows a Message the No JRE found, what should I do?
I've just had this problem too, with a properly installed x64 JRE 8u45. Don't know if the Windows exe installer expects an x86 jvm?
Anyway, download the binary package zip instead from Tigris (dead) GitHub Releases and unzip somewhere. It runs fine from there * with argouml.bat, you just don't get a start menu entry added.
EDIT: Your PATH must be correct to find the java.exe, easy way to check is to open a new Cmd shell (Start > Run... > cmd) and type java -version you should get something back from the jvm
Check if JAVA_HOME environment variable is set (it should contain the directory your JRE is installed to).
I have the same problem on WIN7_X64.
I have installed it manually, here some steps:
Download the argouml-0.34 zip file
Extract the archive to install_dir Ex: C:\Program Files (x86)\ArgoUML-0.34 (to make it visible for all users)
Create a shortcut ArgoUML in C:\ProgramData\Microsoft\Windows\Start Menu\Programs with the following information:
Target: "install_dir\argouml.jar" Ex: "C:\Program Files (x86)\ArgoUML-0.34\argouml.jar"
Start in: "install_dir" Ex: "C:\Program Files (x86)\ArgoUML-0.34"
Change Icon...: browse to install_dir\ArgoUML.ico Ex: C:\Program Files (x86)\ArgoUML-0.34\ArgoUML.ico
You ca use argouml.bat but the above steps are more than enough.
I installed windows x64 first but it didn't work.
Then I installed windows x86 offline and it worked.
Simple!
First install 86 bit jre(Windows x86 Offline) from oracle.com then try to install ArgoUML.I think it will work.It has worked for me.Try to download from below given links for jre and ArgoUML.
jre link-
https://www.oracle.com/java/technologies/javase-jre8-downloads.html
ArgoUML link-
https://argouml.en.softonic.com/download
I was able to use installer by first installing Java x86/32 bit JRE
First install the jre-8u271-windows-x641.exe
Install argouml
Uninstall the jre-8u271-windows-x641.exe
Move to the folder: C: \ Users \ nameuser \ AppData \ Roaming \ Microsoft \ Windows \ Start Menu \ Programs \ ArgoUML right-click on ArgoUML then property under target: "C: \ Program Files \ Java \ jdk-15 \ bin \ javaw.exe "-Xms64m -Xmx512m -jar" C: \ Program Files (x86) \ ArgoUML \ argouml.jar "specify the bin path of your jdk me mine is C: \ Program Files \ Java \ jdk- 15 \ bin \ javaw.exe
Execute the file (double click) .bat: C: \ Program Files (x86) \ ArgoUML \ argouml.bat
Is there a way to convert a Java application into a Mac OS X executable app?
I use NetBeans to develop in Java, and I'd like to "pack" the "dist" folder into an app (just for convenience)
Use the Apple Java Extensions and its Guide
The Apple Java Extensions contains a very complete development guide with information on the deployment of Java applications on Mac OS X and the production of application bundles. It also introduces other aspects of the Apple Java Extensions, like the support for integration with the standard Mac OS X UI.
Other references:
JarBundler.
Make a Mac OS X App Bundle
Creating a osx app bundle in Java registered to a protocol url
There is a library that let's you package your Java app
Packr: https://github.com/libgdx/packr
Packages your JAR, assets and a JVM for distribution on Windows (ZIP), Linux (ZIP) and Mac OS X (.app), adding a native executable file to make it appear like the app is a native app.
It can even minimize the JRE for you.
jar2app
Packr is a great tool, but at the time I found that I wanted something "easier to use", so jar2app was born. I know this is an old question but perhaps other people might find this program easier to use than other alternatives. If they don't, there's a direct reference in the FAQ to other alternatives (such as Packr).
You can use javapackager tool to build the application and wrap it in into an installer, the following commands show how to convert a jar file into a bundle file:
commands
mkdir -p package/macosx
cp Test.icns package/macosx
jdk=$(/usr/libexec/java_home)
$jdk/bin/javapackager -deploy -native dmg \
-srcfiles Test.jar -appclass package.Test -name Test \
-outdir deploy -outfile Test -v
cp deploy/bundles/Test-1.0.dmg installer.dmg
ls -l
open installer.dmg
To change the application icon and more info MacJava.
As of JDK14 there is also 📦 jpackage (JEP-392), currently promoted from incubation phase to a production-ready feature.
Example usage that worked with an swt app (assumes all the required jar files reside in the files folder; you can also provide a custom resource folder with --resource-dir):
jpackage --type dmg \
-i files \
-n Bigly \
--main-class com.biglybt.ui.Main \
--main-jar BiglyBT.jar \
--java-options -XstartOnFirstThread \
--mac-package-name BiglyBt \
--icon app.icns \
--verbose
For the full option list use:
jpackage --help
WARNING: It's probably debatable whether it's a bug or not, and maybe it will be addressed in a future release, but in the current version, if you specify the input folder as -i ., and do not provide a custom destination with --dest then jpackage will bundle everything in the current folder... including the bundle it just created, i.e. it goes recursive on itself when . is both the input folder and the output :D .
Since some of the links in the accepted answer are no longer available or suitable in 2020, 8 years from the question was asked, I would like to share my findings that I confirmed working today.
There is a tool, javapackager, shipped with java, can package java application on Windows, Linux, macOS for you.
Here is the official manual: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html
(Also there are other helpful tools here: https://docs.oracle.com/javase/8/docs/technotes/tools/ )
For packaging a mac application, I used this command:
javapackager \
-deploy \
-native image \
-srcdir ./csv-encrypt-tool-mac \
-srcfiles csv-encrypt-tool.jar \
-srcfiles dict \
-srcfiles config \
-srcfiles log \
-outdir ./dist \
-outfile csv-encrypt-tool \
-appclass some.package.CsvEncToolApp \
-name "csv-encrypt-tool" \
-title "csv-encrypt-tool" \
-nosign \
-v \
-BjvmOptions=-Xmx4096m \
-BmainJar=csv-encrypt-tool.jar \
-Bicon=icon.icns
And this is the explanation:
-deploy \ # Assembles the application package for redistribution with sys JRE
-native image \ # Build a .app file. If you want a .dmg, use -native dmg
-srcdir ./csv-encrypt-tool-mac \ # directory where my jar and resource files in
-srcfiles csv-encrypt-tool.jar \ # my executable jar, path relative to -srcdir
-srcfiles dict \ # one of my resource directories, path relative to -srcdir
-srcfiles config \ # another one of my resource directories, path relative to -srcdir
-srcfiles log \ # again, one of my resource directories, path relative to -srcdir
-outdir ./dist \ # where I want the package to be put
-outfile csv-encrypt-tool \ # the output file name without extension, the final file (or bundle which is a directory actually) will be csv-encrypt-tool.app
-appclass some.package.CsvEncToolApp \ # the class with main method, which is the entry point of the whole app
-name "csv-encrypt-tool" \ # the name (not very sure what this is for)
-title "csv-encrypt-tool" \ # the title (not sure what it is either)
-nosign \ # not sign the app since this is just an internal tool, if you want to publish it, signing is necessary
-v \ # verbose
-BjvmOptions=-Xmx4096m \ # I need 4GB max heap size
-BmainJar=csv-encrypt-tool.jar \ # the jar file with main class
-Bicon=icon.icns # the icon
After the command is executed, there will be some files and directories created in dist, where I want the package be, and one of the directories is bundles. The application is put in there.
Since I just built an internal tool, there is no need to sign and packaged without other production ready options. You can refer to the official manual for help.
Hope this help others who do not know how to package an application on macOS in 2020, just like me.
So none of these options worked for me (maybe because I am running OS X 10.15, maybe because most of these projects are years old, who knows). Installing Catalina made the existing app I had built around the Java app no longer work.
Ultimately, this post helped: Just use Automator to run a script that runs the java command to launch the jar. I wanted to make an app to launch Colossus, a Java version of the old Avalon Hill board game Titan. I wrote a shell script that looks like:java -Xmx256m -jar /my/path/to/the/game/Colossus.jar net.sf.colossus.appmain.Start and then created an automator application whose only action was "Run Shell Script" that launches that script. Works like a charm, no installing Ant, no command line apps requiring you to download java vms, and best of all it uses an Apple tool so will work with newer versions of OS X.
You can try this app , it bundles your jar file into Mac app
Edit: it's easy to use , select the Jar file and an Icon. Here you can see the screen shoot.
https://github.com/aprsn/Mac-App-Creator