The javapackager is unable to generate a dmg on macOS - java

I am trying to generate a dmg from a jar using the javapackager.
Here is what I put into terminal:
cd "/Users/name/Documents/JarToApplication"
jdk=$(/usr/libexec/java_home -v 1.8)
$jdk/bin/javapackager -deploy -native dmg -BappVersion=8 -name DMSLauncher -srcdir . -srcfiles DMSLauncher.jar -appclass com.blockhead7360.dms.launcher.DMSLauncher -Bicon=package/macosx/DMSLauncher.icns -outdir deploy -outfile DMSLauncher -v
And it runs until here:
Running [osascript, /var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx/DMSLauncher-dmg-setup.scpt]
/var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx/DMSLauncher-dmg-setup.scpt:635:742: execution error: Finder got an error: The operation can’t be completed because there is already an item with that name. (-48)
java.io.IOException: Exec failed with code 1 command [[osascript, /var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx/DMSLauncher-dmg-setup.scpt] in unspecified directory
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:165)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:138)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:132)
at com.oracle.tools.packager.mac.MacDmgBundler.buildDMG(MacDmgBundler.java:376)
at com.oracle.tools.packager.mac.MacDmgBundler.bundle(MacDmgBundler.java:92)
at com.oracle.tools.packager.mac.MacDmgBundler.execute(MacDmgBundler.java:556)
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:352)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:319)
at com.sun.javafx.tools.packager.Main.main(Main.java:476)
Config files are saved to /var/folders/z5/n802xjnx49l4535kq63992280000gn/T/fxbundler8419176091447096668/macosx. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DMG Installer" (dmg) failed to produce a bundle.
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:354)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:319)
at com.sun.javafx.tools.packager.Main.main(Main.java:476)
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
I went to the file that it said it was having a problem with (DMSLauncher-dmg-setup.scpt) and when I ran the script manually this is what it said:
Can anyone assist me in fixing this problem? Thank you.

In case someone still sees the problem, what I did to resolve it was to check /Volumes folder and eject the volume. Here the volume would be 'DMSLauncher'.

Related

Jenkins - Locating maven-wrapper.properties in wrong path

Below is the snippet from scripted pipeline(Jenkins):
sh 'echo ${WORKSPACE}'
env.PATH="${WORKSPACE}/xyz-app:${env.PATH}"
sh '${WORKSPACE}/xyz-app/mvnw clean install'
that gives below error:
+ /app/jenkins/workspace/CU_project/for_xyz/xyz-app/mvnw clean install
/app/jenkins/workspace/CU_project/for_xyz/xyz-app/mvnw: 236: /app/jenkins/workspace/CU_project/for_xyz/xyz-app/mvnw: cannot open /app/jenkins/workspace/CU_project/for_xyz/.mvn/wrapper/maven-wrapper.properties: No such file
/app/jenkins/workspace/CU_project/for_xyz/.mvn/wrapper/maven-wrapper.jar: No such file or directory
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
echo ${WORKSPACE} gives /app/jenkins/workspace/CU_project/for_xyz
As per the above error: /app/jenkins/workspace/CU_project/for_xyz/.mvn/wrapper/maven-wrapper.properties is wrong path for file maven-wrapper.properties.
Correct path is /app/jenkins/workspace/CU_project/for_xyz/xyz_app/.mvn/wrapper/maven-wrapper.properties
How to configure workspace for mvnw to pick arguments from correct path?

Javapackager - NoSuchFileException while copying libraries JDK 9

When I use the javapacker command, I get a NoSuchFileException when it should copy the libraries to the app folder. I'm running the following command:
javapackager -deploy -nosign -v -native image -name test
-appclass test.Test
-srcdir "E:\projects\test\target"
-srcfiles test-1.0.jar;lib
-outdir "E:\projects\test\target\dist"
Anything seams to work fine, but i get the NoSuchFileException inside the output and the libraries inside the lib folder are missing (did not get copied).
Running [D:\Java64\jdk-9.0.4\bin\java.exe, -version]
Creating app bundle: test in E:\projects\test\target\dist
"Adding modules: [java.rmi, java.sql, javafx.web, ... long list ...
outputDir = E:\projects\test\target\dist\test\runtime
modulePath = [D:\Java64\jdk-9.0.4\jmods]
addModules = [java.rmi, java.sql, javafx.web, ... long list ...
limitModules = []
excludeFileList = .*\.diz
stripNativeCommands = true
userArguments = {}
Using default package resource [icon] (add package/windows/test.ico to the class path to customize)
Using default package resource [Template for creating executable properties file.] (add package/windows\test.properties to the class path to customize)
Running [D:\Java64\jdk-9.0.4\bin\javapackager.exe, --icon-swap, C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.ico, E:\projects\test\target\dist\test\test.exe]
Icon File Name: C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.ico
Executable File Name: E:\projects\test\target\dist\test\test.exe
Running [D:\Java64\jdk-9.0.4\bin\javapackager.exe, --version-swap, C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.properties, E:\projects\test\target\dist\test\test.exe]
Resource File Name: C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows\test.properties
Executable File Name: E:\projects\test\target\dist\test\test.exe
Exception: java.nio.file.NoSuchFileException: E:\projects\test\target\lib\animal-sniffer-annotations-1.14.jar -> E:\projects\test\target\dist\test\app\lib\animal-sniffer-annotations-1.14.jar
Config files are saved to C:\Users\XXX\AppData\Local\Temp\fxbundler15945263774290817340\windows. Use them to customize package.
Result application bundle: E:\projects\test\target\dist
I don't know what the following line of the output is trying to tell me. The file clearly exists inside my lib folder and the javapackager did find it itself by looking inside the lib folder, that I provided with the -srcfiles test-1.0.jar;lib argument.
Exception: java.nio.file.NoSuchFileException: E:\projects\test\target\lib\animal-sniffer-annotations-1.14.jar -> E:\projects\test\target\dist\test\app\lib\animal-sniffer-annotations-1.14.jar
Any idea why javapacker complains that the file would not exist?
As per https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719,
-srcfiles should be provided with a list of files. lib is a directory. I would try using -srcdir.
Also, if you get
Exception: java.lang.Exception: Error: Modules are not allowed in srcfiles
it means you have to use --module-path, and then set the main module using -m <module name>

How do I bundle a Custom C Shared Library with Java Application in Cloud Foundry?

I have previously been deploying a java application successfully in Cloud Foundry. However, now the developers have added a shared library compiled from C. I have added the .so to the .zip file (I'm using universal packager and deploying to Cloud Foundry by zip file) and ensured the .so is executable. However, when I deploy I get an error:
2016-12-23T14:39:01.013+00:00 [STG/0] [OUT] -----> Java Buildpack Version: eba4df6 | git://github.com/cloudfoundry/java-buildpack.git#eba4df6
2016-12-23T14:39:01.017+00:00 [STG/0] [ERR] [Buildpack] ERROR Compile failed with exception #<RuntimeError: No container can run this application. Please ensure that you’ve pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2016-12-23T14:39:01.017+00:00 [STG/0] [ERR] No container can run this application. Please ensure that you’ve pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2016-12-23T14:39:01.022+00:00 [STG/0] [ERR] Failed to compile droplet
2016-12-23T14:39:01.024+00:00 [STG/0] [OUT] Exit status 223
So my understanding is that I need to created a Custom Buildpack from the Java Buildpack. However, I am getting stuck with the code at this point:
https://github.com/ONSdigital/java-buildpack/blob/master/bin/compile#L28
# Adding crf tagger library
status "Adding crf tagger support"
cp $bp_dir/parsers/src/main/resources/libbackend.so $build_dir/vendor/
# update the PATH
status "Building runtime environment"
mkdir -p $build_dir/.profile.d
echo "export PATH=\"$HOME/bin:\$HOME/vendor/:\$PATH\";" > $build_dir/.profile.d/crftagger.sh
echo "export LD_LIBRARY_PATH=\"\$HOME/vendor/\";" >> $build_dir/.profile.d/crftagger.sh
From what I can gather I only need to modify the compile stage. What do I need to do to copy over the .so and have the Buildpack run successfully.
Please take a look to this https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile
Pre-Runtime Hooks that's you need. I can't give you more details because you haven't provided enough information (project structure, do you have .profile in you root and etc.).
If you need to add shared libs try to use attr_reader :additional_libraries https://github.com/cloudfoundry/java-buildpack/blob/master/docs/extending-droplet.md

Compilation failure in JNativeHook

Trying to compile this https://github.com/kwhat/jnativehook/wiki/Compiling
made it as far as the step where I have to run ant all to build.
Compile fails with the following in command prompt.
[javac] Fatal Error: Unable to find package java.lang in classpath or bootcl
asspath
BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:394: Co
mpile failed; see the compiler error output for details.
Total time: 0 seconds
EDIT: I just copied the rt file into the directory i'm trying to compile. I got past the first error but now I'm getting
ava\org\jnativehook\mouse\NativeMouseWheelListener.java
download-libuiohook:
bootstrap-libuiohook:
[echo] Bootstrapping libUIOHook...
[autoreconf] autoreconf --verbose --force --install
BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:351: Ex
ecute failed: java.io.IOException: Cannot run program "sh" (in directory "C:\Use
rs\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\src\libuiohook"): Creat
eProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav
a13CommandLauncher.java:58)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496)
at org.jnitasks.autotools.AutoreconfTask.execute(AutoreconfTask.java:113
)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
e file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 24 more
Total time: 1 second
Still diligently trying to figure this out in the mean time.
Update:
I think I've been going about this wrong. I tried doing this inside MINGW64 which is probably how I should have been doing it.
Sadly still get an error I'm looking into.
compile-java:
[echo] Compiling Java source...
download-libuiohook:
bootstrap-libuiohook:
[echo] Bootstrapping libUIOHook...
[autoreconf] autoreconf --verbose --force --install
[autoreconf] autoreconf: Entering directory `.'
[autoreconf] autoreconf: configure.ac: not using Gettext
[autoreconf] autoreconf: running: aclocal --force -I m4
[autoreconf] aclocal-1.15: error: aclocal: file '/msys64/usr/share/aclocal/xsize .m4' does not exist
[autoreconf] autoreconf: aclocal failed with exit status: 1
BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:351: ex ec returned: 1
Total time: 2 seconds
UPDATE:
Wow so how many shells does msys64 have. I've now tried what seems to be the last and final shell msys2_shell.bat and its gotten even further but still fails.
Now I get
JNativeHook/bin --enable-debug --enable-quiet --enable-static --disable-shared --with-pic
[configure] checking build system type... x86_64-pc-msys
[configure] checking host system type... x86_64-pc-msys
[configure] checking target system type... x86_64-pc-msys
[configure] checking for a BSD-compatible install... /usr/bin/install -c
[configure] checking whether build environment is sane... yes
[configure] checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
[configure] checking for gawk... gawk
[configure] checking whether make sets $(MAKE)... yes
[configure] checking whether make supports nested variables... yes
[configure] checking for style of include used by make... GNU
[configure] checking for gcc... clang
[configure] configure: error: in `/c/Users/George/Downloads/sounds/JNativeHook-2.0.1/JNativeHook/bin/libuiohook':
[configure] checking whether the C compiler works... no
[configure] configure: error: C compiler cannot create executables
[configure] See `config.log' for more details
BUILD FAILED
C:\Users\George\Downloads\sounds\JNativeHook-2.0.1\JNativeHook\build.xml:361: exec returned: 77
Total time: 37 seconds
So close.
UPDATE:
Installed clang and now get this detailed error from the config.log file.
configure:3580: checking whether the C compiler works
configure:3602: clang -march=armv6j -mfpu=vfp -mfloat-abi=hard -Os -g -pipe -fomit-frame-pointer -flto -ffat-lto-objects -fno-stack-protector -Wl,--as-needed,-O1 -flto conftest.c >&5
clang.exe: warning: optimization flag '-ffat-lto-objects' is not supported
clang.exe: error: 'i686-pc-windows-gnu': unable to pass LLVM bit-code files to linker
configure:3606: $? = 1
configure:3644: result: no
configure: failed program was
:
Ok so for future JNativeHook compiler noobies like myself doing this on windows 8.1 here is what I had to do to get this working.
Aside from following all the steps in the compile for windows section provided on their git.
You also need to...
Download LLVM for windows.
Copy your rt.jar into the JNativeHook directory.
And make sure absolutely make sure that you've deleted any build.properties generated from failed builds.
That should get it working.
Dont forget to run ant distclean first if you are trying to compile 2.0.1. I botched the package process by forgetting to include the build.properties file in the exclude list for the zip file. I think that will also fix your rt.jar copying issue. It may solve all of your issues ;) Anyway, 2.0.2 will fix the problem and is scheduled for release on Sunday.

How to use Compass through JRuby, for embedding in my soft'?

I've to "compile" compass files dynamically in my java soft'. So, following explications found on stackoverflow, I've done these steps :
Get JRuby (1.7.3), configure PATH to jruby.jar and binaries (gem, rake ...) and learn to launch ruby script from Java
Get compass and dependancies gems into a local directory, using following command line
gem install -i ./compass compass
=> So I get a directory ./compass/ containing bin, cache,doc, gems & specifications directories.
Put gems in a jar using following command line (think to use a jar name which is not the same as the gems, to avoid JRuby "require" the jar instead of the gems)
jar cf compass-lib.jar -C compass .
Write a test script test.rb in local directory to test my jar. It contains :
require 'compass'
Compass.add_configuration(
{
:project_path => '.',
:sass_path => 'styles/scss',
:css_path => 'styles/css'
},
'custom' # A name for the configuration, can be anything you want
)
Compass.compiler.compile('test.scss', 'test.css')
Execute this script with JRuby, with following command line :
jruby -I . -rcompass-lib.jar test.rb
And get this error ...
Unable to load Sass. Please install it with one of the following commands:
gem install sass --pre
LoadError: no such file to load -- jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/s
ass-3.2.8/lib/sass/../sass
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/sass-3.2.8/lib/sass/ver
sion.rb:5
require at org/jruby/RubyKernel.java:1027
(root) at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
require at org/jruby/RubyKernel.java:1027
(root) at jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/sass-3.2.8/lib/sass.rb:
9
(root) at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:60
(root) at jar:file:C:/jruby-1.7.3/lib/jruby.jar!/gems/compass-0.12.2/lib/comp
ass/dependencies.rb:6
each at org/jruby/RubyArray.java:1613
(root) at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
require at org/jruby/RubyKernel.java:1027
require at c:/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at test.rb:1
An idea of the problem and, maybe, of solution ? ;) Thanks by advance.
[UPDATE #1]
After Jörg W Mittag obvious suggestion, the error disapear. Thanks ;) Now, it just don't find the scss file, so it's a "normal problem" ;)
[UPDATE #2]
Having used compass with success in IRB, it's time to transpose the test through Java. So, I wrote some lines in Java to execute my ruby script, using only absolute path to avoid problems in a first time.
InputStream myFile = ISRessources.getFile("C:/Path/To/My/test.rb");
new ScriptingContainer().runScriptlet(myFile, "test.rb");
But ... how to "load" my compass-lib.jar ? What's the equivalent of the -r in JRuby ? I've tried to includ gems into jruby.jar, to add compass-lib.jar in externals jars in java build path, but both don't work, I still have :
LoadError: no such file to load -- compass
require at org/jruby/RubyKernel.java:1027
(root) at test.rb:1
Any idea ?
The error message says:
Unable to load Sass. Please install it with one of the following commands:
gem install sass --pre

Categories