Perché Launch4j non trova installato JDK?
Ho Launch4j e JDK installati sul mio computer e sto cercando di convertire jar-file in exe. Quando avvio Launch4j ottengo il seguente errore:
Questa applicazione richiede un Java Runtime Environment 1.6.0
Come posso risolvere questo problema? Qual è la strategia di ricerca Launch4j per trovare jres/jdks installati?
Versione JDK:
java -version
Uscita:
Java versione " 14 " 2020-03-17 Java (TM) SE Runtime Environment (build 14+36-1461) Java HotSpot (TM) VM server a 64 bit (build 14+36-1461, misto modalità, condivisione)
Ho JDK-path in entrambe le variabili PATH e JAVA_HOME. Ho provato a disinstallare JDK e installare JRE, ma prima ho bisogno di compilare *.java a *.file di classe con il comando javac. Quindi in questo caso ho diverse versioni di JDK e JRE.
La documentazione ufficiale dice:
Launch4j richiede un file di configurazione xml per ogni output eseguibile.
Quindi posso usare il tag jrecon l'attributo jdkPreference per specificare una preferenza per un runtime JRE pubblico o JDK privato nel file di configurazione. Ma come posso aggiungere questo per costruire.file xml?
Costruire.xml:
<project name="launch4j" default="compile" basedir=".">
<property name="src" location="src" />
<property name="lib" location="lib" />
<property name="build" location="build" />
<property name="jar" location="./${ant.project.name}.jar" />
<property name="launch4j.dir" location="." />
<property name="maven" location="maven" />
<path id="dist.classpath">
<pathelement path="${build}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<tstamp />
<mkdir dir="${build}" />
</target>
<target name="compile" depends="init" description="compile the source">
<javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" source="1.6" debug="on" includeantruntime="false" />
<copy todir="${build}/images">
<fileset dir="${src}/images">
<include name="**/*" />
</fileset>
</copy>
<copy todir="${build}">
<fileset dir="${src}">
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="jar" depends="compile" description="create jar">
<fileset dir="${lib}" id="lib.dist.fileset">
<include name="**/*.jar" />
</fileset>
<pathconvert pathsep=" " property="dist.classpath" refid="lib.dist.fileset">
<map from="${lib}" to="./lib" />
</pathconvert>
<!-- Put everything in ${build} into a jar file -->
<jar jarfile="${jar}">
<fileset dir="${build}" excludes="**/messages_es.properties" />
<manifest>
<attribute name="Main-Class" value="net.sf.launch4j.Main" />
<attribute name="Class-Path" value=". ${dist.classpath}" />
</manifest>
</jar>
</target>
<target name="demo" depends="jar" description="build the demos">
<ant dir="./demo/ConsoleApp" inheritAll="false" />
<ant dir="./demo/SimpleApp" inheritAll="false" />
</target>
<target name="clean" description="clean up">
<delete dir="${build}" />
<delete file="${jar}" />
<ant dir="./demo/ConsoleApp" target="clean" inheritAll="false" />
<ant dir="./demo/SimpleApp" target="clean" inheritAll="false" />
</target>
<target name="switch-to-maven" description="switch project to maven">
<copy todir="." overwrite="true">
<fileset dir="${maven}">
<include name="**/*" />
</fileset>
</copy>
<delete dir="${lib}" />
<mkdir dir="./target" />
</target>
</project>
Grazie
2 answers
Launch4j sembra essere limitato con le nuove versioni java... Nell'ultimo aggiornamento vengono visualizzate informazioni dettagliate sulla jvm supportata, l'ultima è 1.8.9 e c'è un ticket sulla conformità con java 9 e versioni successive... changelog e biglietti launch4j
Invece di avviare il launch4j.exe come eseguibile di Windows, è possibile avviare il lancio4.vaso con il tuo jdk. Pertanto, contrassegnare il launch4j.jar in Esplora file, fare clic con il tasto destro del mouse, scegliere Apri con e fare riferimento al jdk installato, ad esempio Open JDK platform binary