I ran a java executable file using the following command
java -cp .;aa/bb/cc/dd/Main.jar aa.bb.cc.dd.Main
where aa.bb.cc.dd is the package that has all the .java, .class, and Main.jar files
and this package is inside the src folder from where I am running this command.
I am getting an error
cannot execute binary file: Exec format error
Can anyone tell me where I am going wrong.
asked Nov 29, 2014 at 12:52
1
Semi-colon in bash is used to separate commands. So in your case
java -cp .;aa/bb/cc/dd/Main.jar aa.bb.cc.dd.Main
java -cp . and aa/bb/cc/dd/Main.jar aa.bb.cc.dd.Main are considered as two separate commands and executed in sequence.
The issue can be fixed by changing the «;» to «:».
The path delimiter for java class path is «:» and not «;».
answered Jan 27, 2020 at 7:38
![]()
I’m trying to run a program, but it gives an error:
bash: ./program: cannot execute binary file: Exec format error
The result of file program was:
program: ELF-32-bit LSB executable, ARM, EABI4 version 1 (SYSV), dynamically linked (uses share libs), for GNU/LINUX 2.6.16, not stripped
How can I fix this?
I’m using Ubuntu 14.04.2 (amd64) with VMware. I also tried using Ubuntu i386, but the result was the same.
asked Jul 15, 2015 at 5:30
Soongeun HwangSoongeun Hwang
1,5012 gold badges9 silver badges4 bronze badges
1
You’re trying to run an executable compiled for an ARM architecture on an x86-64 architecture, which is much like asking your processor who only speaks English to take directions in Chinese.
If you need to run that executable you have two choices:
-
Get an x86-64 version of the executable (by any mean; if you’re unable to get an x86-64 version of the executable but you’re able to get its source code, you can try to recompile it on the virtual machine);
-
Install Ubuntu Server for ARM in place of Ubuntu 14.04.2 (amd64). This requires either a physical machine running on an ARM architecture or a virtualization software that can emulate it.
answered Jul 15, 2015 at 5:39
![]()
1
This can also occur if you attempt to run an x86-64 executable on a 32-bit platform.
In one specific instance, I downloaded Visual Studio Code and tried to run it on my Ubuntu installation, but I hadn’t realized that I had installed 32-bit Ubuntu in this VM. I got this error, but after downloading the 32-bit version, it ran without issue.
answered Sep 10, 2015 at 23:44
It is often possible to run an ARM executable image on an amd64 system if you install the binfmt-support, qemu, and qemu-user-static packages:
sudo apt install binfmt-support qemu qemu-user-static
qemu will then perform syscall emulation when you run the executable. This works for most ARM binaries but there are a few that may not run correctly.
![]()
answered Oct 27, 2016 at 6:41
Nathan OsmanNathan Osman
31.7k40 gold badges176 silver badges259 bronze badges
2
Such error may occur if all of the following are true:
- Executable is not a file but a link
- You run run it inside VM
- File is located in shared folder
- Your host is Windows.
If you got that file, let’s say, in archive — try to unpack it inside VM, in some directory inside virtual drive, not folder mapped to your host machine hard drive, for example /myNewDir/
![]()
wjandrea
13.8k4 gold badges46 silver badges94 bronze badges
answered Nov 13, 2015 at 22:22
PavelPavel
3531 gold badge3 silver badges10 bronze badges
1
If more than one java is installed on the system this might happen and not set as default. On Ubuntu14.04 LTS I could get it resolved by executing following and choosing the java I needed.
sudo update-alternatives --config java
[sudo] password for user:
update-alternatives: warning: /etc/alternatives/java has been changed (manually or by a script); switching to manual updates only
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode
I choose 2 and set openjdk-8 as a default. Which did not show the Exec format error.
![]()
Videonauth
32.6k16 gold badges102 silver badges119 bronze badges
answered Jun 6, 2016 at 13:43
You must compile your file using an appropriate CPU architecture (x86 for example) and copy the .exe file on your linux machine. Then you can install mono on your linux machine and issue the following command:
mono myprogram.exe
![]()
muru
188k50 gold badges459 silver badges709 bronze badges
answered Feb 28, 2016 at 19:49
1
This can also happen if the binary uses a libc implementation which is not libc, such as musl. These days this specific problem is most likely encountered when trying to run a binary with libc in a Docker container with an image based on alpine. There is nothing that can be done to the binary itself to support both environments, because the libc implementation must always be linked statically, i.e. built directly into the binary, for reasons.
answered Jul 16, 2019 at 16:44
I got this error trying to run a zip file containing an executable rather than extracting it and running the executable itself xD
In addition to the other answers offered here, I suppose there would be a lot of file types that aren’t intended to be executable which could cause this error.
answered May 19, 2020 at 6:05
![]()
1
This is another special case: WSL (Windows Subsystem for Linux) by default(!) only supports 64bit executables. I think this is a rather unusual behaviour, as normally there is a backwards compatibility.
(Even more special is that selecting 64bit in a formerly 32bit project of Windev won’t fix your issue. You need to start a new project, selecting 64bit right in the beginning. Tested on Windev 26. This IDE sucks, forced to use it because of working legacy code.)
answered Jul 21, 2022 at 23:23
![]()
PythoNicPythoNic
6761 gold badge5 silver badges15 bronze badges
2
Asked
2 years, 8 months ago
Viewed
2k times
I installed java 11.0.7-open using sdkman and I get this error:
bash: /home/pi/.sdkman/candidates/java/11.0.7-open/bin/java: cannot execute binary file: Exec format error
when running java --version or java -jar some_file.jar (specifically ‘SKlauncher 3-beta.15.jar’).
Why do I get this error and how to make java work?
asked May 12, 2020 at 11:22
![]()
15
Not only 32-bit versus 64-bit is important, but also that the JDK is compiled for the ARM-processor. For that reason I prefer to use BellSoft LibericaJDK which has a Raspberry Pi-version and also includes JavaFX in case you want to run a JavaFX UI-application.
E.g. to use JDK 13 on Raspbian OS:
$ cd /home/pi
$ wget https://download.bell-sw.com/java/13/bellsoft-jdk13-linux-arm32-vfp-hflt.deb
$ sudo apt-get install ./bellsoft-jdk13-linux-arm32-vfp-hflt.deb
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
When this is done, we can check the version again and it should look like this:
$ java --version
openjdk version "13-BellSoft" 2019-09-17
OpenJDK Runtime Environment (build 13-BellSoft+33)
OpenJDK Server VM (build 13-BellSoft+33, mixed mode)
More info on https://webtechie.be/post/2020-04-08-installing-java-and-javafx-on-raspberry-pi/
answered May 20, 2020 at 9:58
FrankFrank
2981 silver badge8 bronze badges
0
Stuck with an annoying error of “Cannot execute binary file“? Then don’t worry. We will provide you with all the working ways which will help you in fixing the problem.
We will also discuss why did the error occurred and similar queries related to it.
Contents
- 1 What is a Binary file
- 2 How to resolve cannot execute binary file
- 2.1 Install GCC and Gfortran library
- 2.2 Unmatched Architecture
- 2.3 Download WienHQ for Ubuntu / MacOS
- 2.4 Provide the permission
- 2.5 Using dos2unix command
- 2.6 Uncompress the file
- 3 What is cannot execute binary file
- 4 Causes for cannot execute binary file
- 5 Fix: Cygwin cannot execute binary file
- 6 Java- Cannot execute binary file
- 7 FAQs on cannot execute binary file
- 7.1 How to execute a binary file in Powershell?
- 7.2 How to rectify “Cannot execute binary file”?
- 7.3 Fix: Bash cannot execute binary files.
- 7.4 Raspberry Pi cannot execute binary files.
- 8 Winding up
- 9 Trending Right Now
What is a Binary file
Binary means two. The two characters: 1, 0 are repeatedly used to store information and data. The text formats which use this binary format are known are binary format. A format can be changed to decimal, ASCII, BCD, or hexadecimal. We type in the ASCII format, but the computer interprets it in binary format.
A file that is written in binary format is known as a Binary file. The extension is “.bin“. These files can be executed in Linux by the syntax: “./file.bin“
How to resolve cannot execute binary file
Try using one of the following methods and check if the nuisance of binary file unable to execute is rectified or not:
Install GCC and Gfortran library
For Linux Operating Systems, type the below code in the PowerShell:
sudo apt-get install gfortran

For installing g++, GCC, and a few more libraries, use the following code:
sudo apt install build-essential

Check if the error is fixed.
Unmatched Architecture
Open the settings of your computer and check if your system is 32 bit or 64 bit.
Now execute this code to check the architecture format of the specific binary file:
file filename
Try downloading the 32 bt binary file from the internet, if available.
Download WienHQ for Ubuntu / MacOS
If you are trying to execute a binary file made through and for Windows Operating Systems, it may not work directly in your Unix systems. You will have to download a package that can transform an unmodified Windows binary to Unix usable ones.
Use the below link to download the WineHQ
https://wiki.winehq.org/Download
Provide the permission
One more reason for cannot execute a binary file is that the permission is not granted. To fix this, type the below in the PowerShell:
chmod +x filename
./filename
Using the sh command
Try the below syntax:
chmod +x filename.bin
sh filename.bin
Using dos2unix command
In Powershell, use the command:
dos2unix filename.bin
Check if it works out or not.
Uncompress the file
Check if the below line aids in executing the file:
xz -d ./filename
chmod +x ./filename
./filename
If your file is in a zipped format, try unzipping the compressed format and executing it as usual.
Remember to place the path address along with the name of the file.
If you download a binary file from the internet and try to execute it in PowerShell, sometimes you may encounter an error known as “Cannot execute binary file.
The Linux Operating System failed to execute (run or open) the specified file you mentioned in the previous line due to technical issues. A few reasons as to why this error has occurred are provided below.
Causes for cannot execute binary file
There can be broadly two reasons for a binary file to show “Cannot execute binary file” error:
- The file is an exe file and is compile only for Windows.
- The bit architecture of your system and the bin file does not match.
Fix: Cygwin cannot execute binary file
You can use Shell commands in Windows after downloading and installing the Cygwin application.
If you have executed:
C:cygwinbinfilename.exe -h always /bin/bash -l ls
Try this syntax:
C:cygwinbinfilename.exe -h always /bin/bash -l -c ls

If still, it didn’t work, try uninstalling and reinstalling all the necessary files of Cygwin again.
Java- Cannot execute binary file
If the Shell or Cmd Prompt window displays an “Exec format error” error, it wants to say that the current version is not compatible with your system.
If you are using AMD/ Intel processes, install the Linux/x64 build from here.
If you are using ARM type of processors: install the Linux-aarch64 build from here.


FAQs on cannot execute binary file
How to execute a binary file in Powershell?
Open Powershell.
type the below syntax:
./filename
In place of the filename, you have to type the address and path along with the file’s name.
How to rectify “Cannot execute binary file”?
1. Install the latest version of GCC and Gfortran library.
2. Check if the architecture bit is the same or not.
3. Download WienHQ.
4. Uncompress the file.
Fix: Bash cannot execute binary files.
The Bash (Bourne Again Shell) is a SHELL command interpreter. If you try to execute a binary file (.bin) using Bash, which can not be read due to improper settings or unzipped file, it will display an error of Bash cannot execute the binary file.
Raspberry Pi cannot execute binary files.
Make sure that you have downloaded the correct version and file for your OS.
Try uninstalling and reinstalling the software:
Winding up
We hope that the above solutions might have helped rectify your issue, and your file got executed.
You can ping us anytime to ask us any of your doubts using the comment section available at the end of the page.
Trending Right Now
-

Resolve Error Code E4301 Using These 4 Exciting Methods
●October 20, 2022
-

15 Incredible Ways to Fix Paramount Plus Keeps Pausing Error
by Amal Santosh●October 20, 2022
-

5 Strategies to Fix Adobe Short Media Token Validation Error Invalid Signature
by Amal Santosh●October 11, 2022
-

Fix the Apple TV 4K Turns off by Itself with 7 Wonderful Ways
by Amal Santosh●October 11, 2022
When I login using SSH, all I can see is this…
-bash: /usr/bin/id: cannot execute binary file
-bash: [: : integer expression expected
I couldn’t do anything in here. Commands such as halt, poweroff, reboot will return command not found.
How can I fix this? I am using Debian Squeeze Linux
asked Jun 12, 2012 at 21:26
9
Usually that error message means Linux doesn’t recognize the file as a shell script or as an executable file.
Typically the cause is running an executable on the wrong architecture — if you try to run x86 executables on an ARM CPU, this message comes up.
Did /usr/bin/id get overwritten, possibly?
answered Jun 13, 2012 at 3:07
![]()
LawrenceCLawrenceC
71.9k15 gold badges123 silver badges211 bronze badges
4
Try to run it using ./executablefilename instead of using sh executablefilename. It’s not a shell script after all.
answered Jun 13, 2012 at 1:27
RidDeBakTiYarRidDeBakTiYar
5563 gold badges6 silver badges10 bronze badges
1
The problem is running a binary for a different processor architecture.
You can use objdump (from binutils) to check architecture of binaries.
You can use uname to check architecture of a machine.
e.g. I encountered this error «cannot execute binary file» when installing FF.Communicator — a firefox plugin for chrome (so I can run pages that use java applets).
- objdump shows the binary is 64-bit elf64-x86-64
-
uname shows my machine is 32-bit i686
$ ./FF.Communicator
bash: ./FF.Communicator: cannot execute binary file
$ uname -mpio
i686 i686 i386 GNU/Linux
$ objdump -a ./FF.Communicator
./FF.Communicator: file format elf64-x86-64
./FF.Communicator -
objdump on a working binary on my machine shows it is 32-bit elf32-i386
$ objdump -a /bin/ls
/bin/ls: file format elf32-i386
Using these tools you can check architectures of machines and binaries — not just intel architectures but any processor.
For Mac OSX users, you can find out the architecture info of a specific file using the «file» command:
$ file filename_here
answered Jun 19, 2015 at 11:55
gaoithegaoithe
5014 silver badges8 bronze badges
I’m making some wild guesses here, but it looks like the following is happening:
- You log in over SSH, triggering
bashto run your~/.profileor~/.bashrcto set up your environment for you (this is normal). - At some point it tries to execute
/bin/idto get your uid, which fails, causing integer expression error, and terminating the script before it can set up your$PATH. - Because your
$PATHis not set, bash is only able to run commands with the full path specified.
Use export PATH=/bin:/usr/bin:/sbin:/usr/sbin to fix the $PATH issue until you can fix the root cause of /bin/id failing.
answered Jun 12, 2012 at 21:51
Darth AndroidDarth Android
37.4k5 gold badges94 silver badges111 bronze badges
This means that you are trying to execute a binary file using your bash script which is not intended to be run as you trying it to be. It is already a binary file and you are trying your $SHELL to parse and run it.
in a very simple example, if you try to run `w’ command like
$ bash w
/usr/bin/w: /usr/bin/w: cannot execute binary file
similarly you might be hitting the same method or as it looks from your code snippet.
While , for the remaining for your commands, Al these halt, shutdown , reboot etc commands are the root owned commands and need super-user prilveges to run and perform the required operation. normal users can’t run them
another explanation is that these commands are placed at /sbin/ and /usr/sbin , which might not be in your $PATH variable ( which is used to validate commands in your custody )
answered Oct 24, 2018 at 14:01
1
binary file consists of machine instructions the processor can understand.
Your operating system does not mean the same executable will run.
move back and forth between the processor instruction set compatible with will usually work well,
if they are not compatible CPU will not be able to understand instructions.
answered Jun 12, 2012 at 22:29
You are running wrong version of the installer, for example, 64bit machine and trying to install 32bit version of the installer.
answered Jul 25, 2018 at 8:43
When I login using SSH, all I can see is this…
-bash: /usr/bin/id: cannot execute binary file
-bash: [: : integer expression expected
I couldn’t do anything in here. Commands such as halt, poweroff, reboot will return command not found.
How can I fix this? I am using Debian Squeeze Linux
asked Jun 12, 2012 at 21:26
9
Usually that error message means Linux doesn’t recognize the file as a shell script or as an executable file.
Typically the cause is running an executable on the wrong architecture — if you try to run x86 executables on an ARM CPU, this message comes up.
Did /usr/bin/id get overwritten, possibly?
answered Jun 13, 2012 at 3:07
![]()
LawrenceCLawrenceC
71.9k15 gold badges123 silver badges211 bronze badges
4
Try to run it using ./executablefilename instead of using sh executablefilename. It’s not a shell script after all.
answered Jun 13, 2012 at 1:27
RidDeBakTiYarRidDeBakTiYar
5563 gold badges6 silver badges10 bronze badges
1
The problem is running a binary for a different processor architecture.
You can use objdump (from binutils) to check architecture of binaries.
You can use uname to check architecture of a machine.
e.g. I encountered this error «cannot execute binary file» when installing FF.Communicator — a firefox plugin for chrome (so I can run pages that use java applets).
- objdump shows the binary is 64-bit elf64-x86-64
-
uname shows my machine is 32-bit i686
$ ./FF.Communicator
bash: ./FF.Communicator: cannot execute binary file
$ uname -mpio
i686 i686 i386 GNU/Linux
$ objdump -a ./FF.Communicator
./FF.Communicator: file format elf64-x86-64
./FF.Communicator -
objdump on a working binary on my machine shows it is 32-bit elf32-i386
$ objdump -a /bin/ls
/bin/ls: file format elf32-i386
Using these tools you can check architectures of machines and binaries — not just intel architectures but any processor.
For Mac OSX users, you can find out the architecture info of a specific file using the «file» command:
$ file filename_here
answered Jun 19, 2015 at 11:55
gaoithegaoithe
5014 silver badges8 bronze badges
I’m making some wild guesses here, but it looks like the following is happening:
- You log in over SSH, triggering
bashto run your~/.profileor~/.bashrcto set up your environment for you (this is normal). - At some point it tries to execute
/bin/idto get your uid, which fails, causing integer expression error, and terminating the script before it can set up your$PATH. - Because your
$PATHis not set, bash is only able to run commands with the full path specified.
Use export PATH=/bin:/usr/bin:/sbin:/usr/sbin to fix the $PATH issue until you can fix the root cause of /bin/id failing.
answered Jun 12, 2012 at 21:51
Darth AndroidDarth Android
37.4k5 gold badges94 silver badges111 bronze badges
This means that you are trying to execute a binary file using your bash script which is not intended to be run as you trying it to be. It is already a binary file and you are trying your $SHELL to parse and run it.
in a very simple example, if you try to run `w’ command like
$ bash w
/usr/bin/w: /usr/bin/w: cannot execute binary file
similarly you might be hitting the same method or as it looks from your code snippet.
While , for the remaining for your commands, Al these halt, shutdown , reboot etc commands are the root owned commands and need super-user prilveges to run and perform the required operation. normal users can’t run them
another explanation is that these commands are placed at /sbin/ and /usr/sbin , which might not be in your $PATH variable ( which is used to validate commands in your custody )
answered Oct 24, 2018 at 14:01
1
binary file consists of machine instructions the processor can understand.
Your operating system does not mean the same executable will run.
move back and forth between the processor instruction set compatible with will usually work well,
if they are not compatible CPU will not be able to understand instructions.
answered Jun 12, 2012 at 22:29
You are running wrong version of the installer, for example, 64bit machine and trying to install 32bit version of the installer.
answered Jul 25, 2018 at 8:43