I created a "hello world" java program and use lauch4j to convert executable jar to .exe file. When I tried to run it in cmd, but nothing printed out. I also tried to run it in launch4j. Log indicates: Executing: C:\Documents and Settings\cnbq84\Desktop\helloworld.exe. But still no "hello world" is displayed.
How to display the "Hello World" msg?
Thanks
Here is my config file:
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui|console</headerType>
<jar>C:\Documents and Settings\cnbq84\Desktop\helloworld.jar</jar>
<outfile>C:\Documents and Settings\cnbq84\Desktop\helloworld.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir></chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<customProcName>false</customProcName>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon></icon>
<jre>
<path>PATH</path>
<minVersion>1.4.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
</launch4jConfig>
You may not be in console mode.
From http://launch4j.sourceforge.net/docs.html
To wrap a jar in console mode use launch4jc.exe and specify the configuration file. launch4jc.exe config.xml
It turns out I finally spot the issue through trial and error...
When I add those lines: hello.HelloWorld hello.HelloWorld Everything works. It seems Launch4j can't find the main() if you do not specify it explicitly.
Thanks.
来源:https://stackoverflow.com/questions/1060530/lauch4j-hello-world-program