I've been looking around for a tutorial on how to compile/run a java file. I know you can run it and compile it with eclipse, and you can type "javac" in terminal (mac), but i would like to send a small program i wrote to a friend, and he can just click on it to run it. Maybe a class file, I don't know. I am running mac btw.
Make it a runnable jar from eclipse. Your main file will run.
A good tutorial if you need @ Create a Java exe file / executable JAR
HTH
First of all create an executable JAR File and then-
You can create-
a batch file(.bat) for windows like this,
@echo off start javaw -jar XYZ.jar
save this file to ABC.bat, now this file is executable, just double click on it and run your program.
an executable file(.exe) for windows, like this,
This is a C program-
#include <string.h> #include <stdlib.h> void main (int argc, char **args) { char *jarfile = "XYZ.jar"; // jar file name... int n = strlen(jarfile); char *cmd = (char *)malloc(n+50); strcpy(cmd, "startw java -jar "); strcat(cmd, jarfile); system(cmd); }
compile this file with any c compiler, now run the executable file(.exe).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.