Exception in Install4j when creating an 32 bit Installer with bundled JRE - install4j

Using Apache ANT I create a JRE bundle of a 32 bit JRE 1.8.202 using createbundle.exe:
<property name="CREATEBUNDLE" value="${install4j.path}/bin/createbundle.exe" />
<exec executable="${CREATEBUNDLE}">
<arg value="-o" />
<arg value="${install4jJREBundleDir}/${CURRENT_JRE_NAME}/" />
<!-- input -->
<arg value="${unzippedJREDirectory}/${JREDirName}/" />
</exec>
<!-- Get filename of created JRE Bundle -->
<fileset id="contents" dir="${install4jJREBundleDir}/${CURRENT_JRE_NAME}/" includes="*.tar.gz" />
<pathconvert property="INSTALL4J_JREBUNDLE" refid="contents" />
Using this bundle I try to create a 32 bit installer for my application:
<target name="installer.internal">
<install4j projectfile="${i4jprojectfile}" verbose="true" mediatypes="${i4jmediatypes}" destination="${dist}" >
<vmParameter value="-Dinstall4j.timestampUrl=${INSTALL4J_TIMESTAMP_URL}"/>
<variable name="BUILD_VERSION" value="${BUILD_VERSION}" />
<variable name="SOFTWARE_VERSION" value="${SOFTWARE_VERSION}" />
<variable name="PLATFORM_DETAIL_STRING" value="${PLATFORM_DETAIL_STRING}" />
<variable name="INSTALL4J_JREBUNDLE" value="${INSTALL4J_JREBUNDLE}" />
</install4j>
</target>
The following error is thrown when creating the installer:
350 [install4j] com.exe4j.a.d: Cannot bundle a 64-bit JRE with a 32-bit media file.
351 [install4j] at com.install4j.b.g.g.a(ejt:97)
352 [install4j] at com.install4j.b.b.a(ejt:175)
353 [install4j] at com.install4j.b.i$a.c(ejt:846)
354 [install4j] at com.install4j.b.i$a.b(ejt:837)
355 [install4j] at com.install4j.b.i.b(ejt:163)
356 [install4j] at com.install4j.Install4JApplication.c(ejt:479)
357 [install4j] at com.exe4j.a.a(ejt:342)
358 [install4j] at com.install4j.Install4JApplication.main(ejt:94)
359 [install4j] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
360 [install4j] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
361 [install4j] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
362 [install4j] at java.lang.reflect.Method.invoke(Unknown Source)
363 [install4j] at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:85)
364 [install4j] at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94)
365 [install4j] at com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:25)
366 [install4j] install4j: compilation failed. Reason: Cannot bundle a 64-bit JRE with a 32-bit media file.
The JRE in the bundle is 32 bit, so the error doesn't really make sense.
Edit: I tried using install4j v7.0.18 and Install4j8.

The architecture is determined from the absolute path of the bundle file. Our bundle file resides in a folder called 'c:\src\Windows10_x64...' Because of the 'x64' in the path ('Windows10_x64') Install4j thought the bundle is 64 bit.
Edit: The solution was to use a relative path for the bundle file omitting the 'Windows10_x64' folder.

Related

Service Builder is giving error with life-ray 7

I'm working on Liferay 7. I'm new to Liferay and I'm experiencing an issue that I spent too much time on.
I have a portlet that I decided to create a Service Builder (named "Employee"). Here is my service.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.test">
<author>sachin.singh</author>
<namespace>crud</namespace>
<entity name="Employee" table="user" local-service="true" remote-service="true">
<column name="iduser" type="int" primary="true" id-type="increment"/>
<column name="name" type="String" />
<column name="secret_code" type="String" />
</entity>
</service-builder>
And when i am building using liferay service builder i am getting this error
[copy] Copying 1 file to D:\tools\com.liferay.portal.plugins.sdk-1.0.11\portlets\firstLiferay-portlet\docroot\WEB-INF\classes
[copy] Copied 3 empty directories to 2 empty directories under D:\tools\com.liferay.portal.plugins.sdk-1.0.11\portlets\firstLiferay-portlet\docroot\WEB-INF\classes
[jar] Building MANIFEST-only jar: D:\tools\com.liferay.portal.plugins.sdk-1.0.11\portlets\firstLiferay-portlet\service-builder-classpath.jar
[delete] Deleting: D:\tools\com.liferay.portal.plugins.sdk-1.0.11\portlets\firstLiferay-portlet\service-builder-classpath.jar.manifest
[java] Java Result: 1
[delete] Deleting: D:\tools\com.liferay.portal.plugins.sdk-1.0.11\portlets\firstLiferay-portlet\service-builder-classpath.jar
[echo] java.lang.NoClassDefFoundError: com/thoughtworks/qdox/model/JavaMethod
[echo] at java.lang.Class.getDeclaredMethods0(Native Method)
[echo] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
[echo] at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
[echo] at java.lang.Class.getMethod0(Class.java:3018)
[echo] at java.lang.Class.getMethod(Class.java:1784)
[echo] at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
[echo] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
[echo] Caused by: java.lang.ClassNotFoundException: com.thoughtworks.qdox.model.JavaMethod
[echo] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[echo] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[echo] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
[echo] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[echo] ... 7 more
[echo] Error: A JNI error has occurred, please check your installation and try again
[echo] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
[echo] Exception in thread "main"
I checked and cross verify,All jars are there in jar library.
Here is the screenshot of added jar:
Especially when you're new, I'd recommend to try again and use Liferay Workspace instead of the (deprecated) plugins-sdk. All of the samples (here's one for service builder) build on this, and plugins-sdk should largely be used only to migrate existing legacy plugins to the latest release.
I'm not sure what your screenshot shows - if it's all of the bundled jars, then it looks horrible. You should only have tiny plugins in times of OSGi bundles, and it definitely looks like those are way too many dependencies.

How to build jnativehook on window 10

I am using jnativehook on my program. I edit source code little and It works well on mac.
But When it is executed on window, I got this error.
8월 18, 2017 10:47:48 오전 org.jnativehook.DefaultLibraryLocator getLibraries
심각: Unable to extract the nativelibrary /org/jnativehook/lib/windows/x86_64/JNativeHook.dll!
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: org.jnativehook.GlobalScreen.getAutoRepeatRate()Ljava/lang/Integer;
at org.jnativehook.GlobalScreen.getAutoRepeatRate(Native Method)
at org.jnativehook.GlobalScreen.<clinit>(Unknown Source)
at SmiPlayer.Main.main(Main.java:75)
... 11 more
Exception running application SmiPlayer.Main
So I tried to build it on Window. I setted JAVA_HOME path and added JNITasks.
But I got this message.
BUILD FAILED
C:\jnativehook-2.1.0\build.xml:345: Execute failed: java.io.IOException: Cannot run program "sh" (in directory "C:\jnativehook-2.1.0\src\libuiohook"): CreateProcess error=2
I tried cross.build.xml too but I god this error.
BUILD FAILED
C:\jnativehook-2.1.0\cross.build.xml:160: The following error occurred while executing this line:
C:\jnativehook-2.1.0\jnitasks\build.xml:76: Compile failed; see the compiler error output for details.
line 160 is 5th line of below code block
Compiling JNITasks source...
<ant antfile="${basedir}/jnitasks/build.xml" dir="${basedir}/jnitasks">
<target name="compile" />
<target name="jar" />
<!-- We need to override the src and bin locations. -->
<property name="dir.bin" value="${basedir}/jnitasks/bin" />
<property name="dir.src" value="${basedir}/jnitasks/src" />
<property name="dir.jar" value="${basedir}" />
<!-- Set a few of the configurable properties. -->
<property name="ant.build.debug" value="${ant.build.debug}" />
<property name="ant.build.javac.compiler" value="${ant.build.javac.compiler}" />
<property name="ant.build.javac.source" value="${ant.build.javac.source}" />
<property name="ant.build.javac.target" value="${ant.build.javac.target}" />
<property name="ant.build.javac.args" value="${ant.build.javac.args}" />
</ant>
</target>
and line 76 is 8th line of below code block
<condition property="ant.build.javac.bootclasspath" value="${env.JDK_HOME}/bundle/Classes/classes.jar">
<available file="${env.JDK_HOME}/bundle/Classes/classes.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${env.JAVA_HOME}/bundle/Classes/classes.jar">
<available file="${env.JAVA_HOME}/bundle/Classes/classes.jar" type="dir" />
</condition>
<condition property="ant.build.javac.bootclasspath" value="${java.home}/bundle/Classes/classes.jar">
<available file="${java.home}/bundle/Classes/classes.jar" type="file" />
</condition>
<fail message="Could not determine ant.build.javac.bootclasspath location. Please set your JDK_HOME / JAVA_HOME environment variable or manually set the ant.build.javac.bootclasspath property to the location of your rt.jar file.">
I didn't tried cross.build.xml on mac yet.
I need some help..
You must compile all the native code separately for each platform. You cannot compile for Windows on mac without a cross compiler like msys2. You can compile a set of binaries on each platform using ant compile-native and combine the lib directories before calling ant jar. The cross.build.xml file is used to cross-compile all platforms from linux. Instructions on cross-compiling are also located in the Wiki.
Your Windows 10 build is failing because you are not using the correct shell to compile from. You must use the mingw32/64 shell to run ant. Again, this is all outlined in the Wiki on the project page.

Using eclipse in order to find the opencv native library doesn't work

I'm attempting to use opencv on an ubuntu installation and am following this tutorial. Everything seemed fine and it even listed amongst the installed parts so I proceeded into this tutorial. This went well up until the moment where you have to add opencv as a user library as it was not amongst the (completely empty) list of libraries found. I have looked throughout the opencv folder and can't find anything like a library either am I missing something? Any idea on how to fix this?
Note that it did manage to produce .jar file however the library is still missing. If it matters opencv is installed in usr/local/src.
If in order fix this you require any extra information feel free to ask in the comments.
This might have something to do with the problem:
ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
thijs#thijs-ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
This is my build.xml:
<property name="src.dir" value="src"/>
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="${ant.project.name}"/>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<sysproperty key="java.library.path" path="${ocvLibDir}"/>
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="rebuild" depends="clean,jar"/>
<target name="rebuild-run" depends="clean,run"/>
running
ulap:/usr/local/src/opencv-2.4.8/opencv/samples/java/ant$ ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
gave me:
clean:
compile:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
[javac] Compiling 1 source file to /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
jar:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar
[jar] Building jar: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar/SimpleSample.jar
run:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java248 in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
[java] at java.lang.Runtime.loadLibrary0(Runtime.java:844)
[java] at java.lang.System.loadLibrary(System.java:1051)
[java] at SimpleSample.<clinit>(Unknown Source)
[java] Could not find the main class: SimpleSample. Program will exit.
[java] Java Result: 1
rebuild-run:
BUILD SUCCESSFUL
Total time: 1 second
According to the first tutorial (how to build OpenCV from source), the result should be a JAR file and a .so native lib in the bin/ directory of your OpenCV directory. In the "SETTING UP ECLIPSE FOR USING OPENCV (JAVA) IN UBUNTU" tutorial, you must create the User Library by following the steps in the tutorial. That process involves browsing your file system to select the OpenCV JAR that was produced by the first tutorial and then selecting the .so file as the native library. Eclipse will not automatically "find" your OpenCV library, you have to configure it to know about it, that's what the second tutorial is doing.
I think you were running the wrong command with ant. You can read the manual here: https://ant.apache.org/manual/running.html
Below is the format to run ant:
ant [options] [target [target2 [target3] ...]]
So maybe your command line should look like:
ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
given that /usr/local/src/opencv-2.4.8/opencv/build/bin contains the opencv-248.jar
As shown on your build.xml file that the property ocvJarDir is pointing to the location of the classpath requires to build the project:
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
And you need to specify the target "rebuild-run" in the command line since your build.xml does not have a default target specified.
Try installing 2.4.6 version. I have similar problems when installing in VS. Older version worked. Maybe it's the same in Eclipse, too.

JavaFX native bundle exe is throwing "JavaFx launcher Exception" where as Executable Jar file is perfectly running

For long time I was facing an issue while running the application jar -
I am obfuscating the JAR using Proguard and that JAR file also contains some resource files like images, .version file, etc along with publicCerts.store file.
So to include resource file into final JAR I had specified all the resource files as
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,*.version,publicCerts.store
but while running my application JAR I was getting execption -
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.javafx.main.Main.a(Main.java:642)
at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
pl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.AssertionError: java.security.KeyStoreException: Uninitiali
zed keystore
at de.schlichtherle.license.LicenseNotary.getPublicKey(Unknown Source)
at de.schlichtherle.license.LicenseNotary.verify(Unknown Source)
at de.schlichtherle.license.LicenseManager.verify(Unknown Source)
at de.schlichtherle.license.LicenseManager.verify(Unknown Source)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29
)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
... 1 more
Caused by: java.security.KeyStoreException: Uninitialized keystore
at java.security.KeyStore.isKeyEntry(Unknown Source)
... 17 more
I thought the obfuscation corrupting the publicCerts.store so use another obfuscation option for publicCerts.store
-adaptresourcefilenames publicCerts.store
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,.version
and it works. When I used to double click on by application jar it is showing my application window but now the native bundle executable (exe) is showing me this dialog in the same case at the same condition.
Edited -
I have debugged the issue and found that it's throwing exception -
java.lang.AssertionError: java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available
I wonder the native bundle executable (exe) is made up from the same executable but the exe is not working. Here is ANT step to deploy the application and create the native bundle exe.
<target name="CreatingExe" depends="SignedJar">
<fx:deploy width="800" height="600" nativeBundles="all" outdir="${dist}" outfile="${app.name}">
<fx:info title="${app.title}"/>
<fx:application name="${app.title}" mainClass="${main.class}"/>
<fx:resources>
<fx:fileset dir="${distBI}" includes="*.jar"/>
<fx:fileset dir="${WorkingFolder}/temp"/>
</fx:resources>
</fx:deploy>
</target>
FYI : I am running my build on Windows 8 O.S., 64 bit machine. I am deploying my JavaFX application in following steps-
Compiling JavaFX Code.
Creating JAR.
Obfuscating code.
Signing Jar
Creating Executable.
Signing Executable.
Build was successful.
How to exclude publicCerts.store from obfuscation? Why the final exe is not working even the application jar is working? Do I need to specify any thing else in fx:deploy task?
When building a JavaFx native bundle the ext folder under <JDK.HOME> doesn't get included. What this folder contain is mostly the security stuff.
<!--Copy the ext library to the runtime lib-->
<copydir src="${java.home}/lib/ext"
dest="${dist.jar.dir}/bundles/{YOUR.PACKAGE.NAME}/runtime/jre/lib/ext"
includes="**/*"
/>

install4j error out with Splash.png is not a valid image file

I saw a post to this very issue and the author have resolved it my edit the png splash file. However,
in my case I did not made any changes to the png file, and yet, i ran into this error with install4j.
Please help if some one have resolved this.
[install4j] java.lang.IndexOutOfBoundsException
[install4j] at java.io.RandomAccessFile.writeBytes(Native Method)
[install4j] at java.io.RandomAccessFile.write(Unknown Source)
[install4j] at javax.imageio.stream.FileImageOutputStream.write(Unknown Source)
[install4j] at com.sun.media.imageioimpl.plugins.bmp.BMPImageWriter.write(BMPImageWriter.java:513)
[install4j] at javax.imageio.ImageWriter.write(Unknown Source)
[install4j] at javax.imageio.ImageIO.write(Unknown Source)
[install4j] at javax.imageio.ImageIO.write(Unknown Source)
[install4j] at com.A.B.D.W(ejt:2330)
[install4j] at com.A.B.D.Q(ejt:2859)
[install4j] at com.A.B.D.L(ejt:1319)
[install4j] at com.A.B.D.N(ejt:463)
[install4j] at com.A.B.D.d(ejt:555)
[install4j] at com.install4j.C.D.F.B(ejt:833)
[install4j] at com.install4j.C.D.B.R(ejt:629)
[install4j] at com.install4j.C.D.I(ejt:3315)
[install4j] at com.install4j.C.D.C(ejt:776)
[install4j] at com.install4j.C.A.A(ejt:1596)
[install4j] at com.install4j.C.B.¦(ejt:1736)
[install4j] at com.install4j.C.B.+(ejt:3290)
[install4j] at com.install4j.C.B.I(ejt:659)
[install4j] at com.install4j.Install4JApplication.?(ejt:3031)
[install4j] at com.A.L.?(ejt:2517)
[install4j] at com.install4j.Install4JApplication.main(ejt:3481)
[install4j] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[install4j] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[install4j] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[install4j] at java.lang.reflect.Method.invoke(Unknown Source)
[install4j] at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
[install4j] at com.exe4j.runtime.WinLauncher.main(Unknown Source)
[install4j] install4j: compilation failed. Reason: com.A.B.E: com.A.B.E: File Splash.png is not a valid image file.
Up to release 4.2.7, install4j included a JAR file
[install4j installation directory]/lib/jai-imageio.jar
This JAR file contains an ancient implementation of javax.imageio and was a leftover from times when that API was not part of the JRE (prior to Java 1.3).
Just delete that JAR file and the problem will most likely go away.