1

I'm having a hard time figuring how to convert jar files with its libraries into an .exe file. I know how to convert jar files(ONLY) to an .exe file using JSmooth but I don't know how to add its libraries in it.

What I'm trying to accomplish is that I wanna execute the file without having the \lib and jar file(s) in the location of .exe file. I want the .exe file to be independent.

'Cause The scenario I've encountered was that I have this .jar file, the lib folder, and the .exe file in the same location. When I try to execute the .exe file nothing's wrong, it worked well. When I try to move away the .exe file from the jar file and the \lib. It won't worked anymore. Is there a way that I can just delete the jar and the lib folder but leaving the .exe file working just fine?

GM-Xile GM-Xile
  • 321
  • 1
  • 8
  • 21

1 Answers1

0

You can run your exe from anywhere depending you have the jars in your classpath. You can make use of environment variable to set the class path and simply put this in your exe:

For windows:

java -classpath .;local.jar MainClass

For unix/linux:

   java -classpath .:local.jar MainClass
Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • 1
    just a side note : While specifying your jars use `;` for windows systems and `:` in linux based systems. – codeMan Jun 23 '13 at 16:40
  • Based on the answer given, I assumed that there is no way wherein I can just copy the .exe file alone, meaning with the \lib and jar file, then transfer it to another pc and execute it without getting any error, am I right? – GM-Xile GM-Xile Jun 23 '13 at 23:02