It would like to know how to create - I mean C++ example - .exe file from .jar file? Do not want to use Launch4j or similar. Just want to do it from scratch.
Asked
Active
Viewed 970 times
-2
-
http://stackoverflow.com/questions/147181/how-can-i-convert-my-java-program-to-an-exe-file – Wes Mar 20 '14 at 19:52
-
I mean C++ working example, not the software. – Ernestas Gruodis Mar 20 '14 at 19:55
2 Answers
1
So the answer is here. It looks like:
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
string getAppName() {
// Creates char array with maximum needed length
char result[MAX_PATH];
// Uses <windows.h> method to retrieve app name. Only Windows OS
std::string(result, GetModuleFileName(NULL, result, MAX_PATH));
char* token;
string name, next = "";
//Iterates until end of tokens of Name string, divided by char -> '\' and '.'
//The only '.' in Filename must be that for ".exe" , error otherwise.
token = strtok(result, "\\.");
while (next != "exe") {
name = next;
token = strtok(NULL, "\\.");
next.assign(token);
}
return name;
}
int main(int argc, char** argv) {
ifstream file; // file stream
string value = "";
string jar_name = "";
string image_name = "splash.gif";
file.open("run.ini");
if (!file) { // file does not exist, so use standard name
jar_name = getAppName();
jar_name += ".jar";
} else {
do {
file >> jar_name;
file >> image_name;
} while (!file.eof());
file.close();
}
//Launch JAVAW command on "jar_name" file with "image_name" splash image
string exec_command = "start javaw -splash:" + image_name + " -jar " + jar_name;
system(exec_command.c_str());
return 0;
}

Ernestas Gruodis
- 8,567
- 14
- 55
- 117
0
#include void main(void) { system("Java < Filename>");
Save as call center.c properties:compile->make as .exe Take the exe file from tc/bin

Devayan
- 1
- 1