I have been searching for many similar posts about this but I still can\'t find my answer. I want to convert a .java program into a Linux executable file, without the .jar e
I found a solution, which is exactly what I want after hours of searching and trying. It is to use the gcj command in linux.
It works like gcc for C and g++ for C++ which compile C or C++ programs into executables.
First install gcj by using the terminal by typing:
sudo apt-get install gcj-jdk
After that, cd into the directory of where the .jar file is located, let's say the .jar file is myFile.jar, then do:
gcj myFile.jar -o newNameofTheFile --main=theMainClassNameofTheFile
to compile the .jar file. And it should work like an executable by just running it in the command line like this:
./newNameofTheFile