Piacenti
Piacenti

Reputation: 1218

Executable won't work after extracted from jar

I have a java program to which I made some optimization by doing part of the code in C++. I included the C++ executable in the self contained runnable jar. When the program runs and I need to use this executable I extract it to the current folder and run it.

The problem that I found is that when I extract the file it no longer seems to be considered an executable. The file works perfectly fine before it is compressed into the jar but I cannot run it in the shell after extracting. I also tried using the java "jar xf" command to extract the file and see if there was a bug on my code and I still find the same problem.

My current version of java is 1.7.0.51 and I'm making the program to run on computers that are stuck on this version of java for now.

Upvotes: 1

Views: 315

Answers (1)

tricklepie
tricklepie

Reputation: 62

When you unpack *.jar file, check the permissions before you proceed. If the you have executable permissions, If you don't have executable permissions, then change them.

chmod +X <executable>

If this doesn't work, check the file format of C++ executable.

file <executable>

Upvotes: 1

Related Questions