Java EXE program

xiaoxiao2021-03-06  27

Principle: 1. Pack the Application program made by his Java into executable JAR files (specified in manifest.mf) 2. Generate executable EXE files with VC , Delphi or other languages, this EXE The function is to call the common command "Java-Jar JAR file name" to achieve the role of using EXE executive JAR files. The DOS command of .exe, incorporate the exe file and JAR file into a C.EXE file, which contains the content of the A.EXE file, but also contains the contents of the B.jar file. When the merge is completed, C. Exe file can be executed with java -jar c.exe, so we can call "Java-Jar program own file name" in the code. Defect: 1. This is the easiest way, still no Drash from JVM 2. No configuration file, when setting ClassPath or other parameters, you need to overwrite the program 3. You can use WinRAR, WinZip Tool to open the EXE file (this is the same as the JBuilder generated EXE file) to give the code: VC Code: #include "stdafx.h" #include "resource.h" #include #include #include int APIENTRY WinMain (hINSTANCE hInstance, hINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {TCHAR exeFullPath [MAX_PATH]; GetModuleFileName (NULL, exeFullPath , MAX_PATH); CHAR CMD [MAX_PATH 20] = "" "; Sprintf (cmd," java.exe -jar / "% s /", exefullpath); Winexec (cmd, sw_hide); return 0;} Delphi code: Program sunking; uses forms, windows; {$ r * .res} begin Winexec (Pchar ('java.exe -jar "' application.exename '"), sw_hide); end.

转载请注明原文地址:https://www.9cbs.com/read-40010.html

New Post(0)