Cannot execute binary file linux java

Java Oracle Installation /usr/bin/java: cannot execute binary file

Minecraft is awesome! But you do not need a jdk unless you plan on developing java.

sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer 

You have some locale setting errors. Here, follow the instructions here and see if that resolves your issue, and let me know if it does: How do I fix my locale issue?
https://help.ubuntu.com/community/Locale

As to you are getting a binary execution error, I’m not to sure. It could be that you have an integrated chip environment using intel / nvidia with optimus. Some more details would help to determine what that is. Run lspci and post those results in your question area please. If it says intel integrated graphics, and somewhere says that you have nvidia, then that is your problem and you will need to install bumblebee and use optirun minecraft so you can use opengl.

Solution 2

I also run into the same issue, found out that it’s because the OS is 32-bit and tried to install 64-bit jdk.

Bash ./program : Cannot Execute Binary File : Exec Format Error

Ubuntu: Java Oracle Installation /usr/bin/java: cannot execute binary file (2 Solutions!!)

Java: cannot execute binary file?

Bash ./ Executable : Cannot Execute Binary file : Exec Format Error

bash: /usr/bin/java: No such file or directory (2 Solutions!!)

Dave

Updated on September 18, 2022

Comments

Hi I’ve been trying for 1 day to get Oracle Java running on Ubuntu. I have a powermac g5 with Ubuntu 12.04 ppc64. uname -a :

Linux LK37 3.2.0-53-powerpc64-smp #81-Ubuntu SMP Thu Aug 22 21:17:14 UTC 2013 ppc64 ppc64 ppc64 GNU/Linux 
[email protected]:~$ sudo lspc [sudo] password for david: sudo: lspc: command not found [email protected]:~$ sudo lspci 0000:00:0b.0 PCI bridge: Apple Inc. CPC945 PCIe Bridge 0000:0a:00.0 VGA compatible controller: NVIDIA Corporation NV43 [GeForce 6600 LE] (rev a2) 0001:00:00.0 Host bridge: Apple Inc. U4 HT Bridge 0001:00:01.0 PCI bridge: Broadcom BCM5780 [HT2000] PCI-X bridge (rev a3) 0001:00:02.0 PCI bridge: Broadcom BCM5780 [HT2000] PCI-X bridge (rev a3) 0001:00:03.0 PCI bridge: Broadcom BCM5780 [HT2000] PCI-Express Bridge (rev a3) 0001:00:04.0 PCI bridge: Broadcom BCM5780 [HT2000] PCI-Express Bridge (rev a3) 0001:00:05.0 PCI bridge: Broadcom BCM5780 [HT2000] PCI-Express Bridge (rev a3) 0001:00:06.0 PCI bridge: Broadcom BCM5780 [HT2000] PCI-Express Bridge (rev a3) 0001:00:07.0 PCI bridge: Apple Inc. Shasta PCI Bridge 0001:00:08.0 PCI bridge: Apple Inc. Shasta PCI Bridge 0001:00:09.0 PCI bridge: Apple Inc. Shasta PCI Bridge 0001:01:07.0 Unassigned class [ff00]: Apple Inc. Shasta Mac I/O 0001:01:0b.0 USB controller: NEC Corporation OHCI USB Controller (rev 43) 0001:01:0b.1 USB controller: NEC Corporation OHCI USB Controller (rev 43) 0001:01:0b.2 USB controller: NEC Corporation uPD72010x USB 2.0 Controller (rev 04) 0001:03:0c.0 IDE interface: Broadcom K2 SATA 0001:03:0d.0 Unassigned class [ff00]: Apple Inc. Shasta IDE 0001:03:0e.0 FireWire (IEEE 1394): Apple Inc. Shasta Firewire 0001:05:04.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5780 Gigabit Ethernet (rev 03) 0001:05:04.1 Ethernet controller: Broadcom Corporation NetXtreme BCM5780 Gigabit Ethernet (rev 03) [email protected]:~$ 
bash: /usr/bin/java: cannot execute binary file 

At the moment I have Installed jdk-7u25-linux-x64.tar.gz in /usr/lib/jvm/jdk1.7.0/bin/ as said in this post I already tried the web install but I get a 404 error. I hope you can help me. I started using Ubuntu yesterday so please give me the complete terminal code, it will be a lot easier for me. For those who care I want to play Minecraft and with the OpenJDK I got a java.lang error. That’s why I want to install Oracle Java.

Читайте также:  Посмотреть проц в линуксе

Источник

Error during the installation of Java: cannot execute binary file: Exec format error

I have feeling that I messed up something badly, I am a new Linux user, so I was trying to install Java… So basically the command that I run in terminal is the following:

-bash: /usr/local/java/jdk-16/bin/java: cannot execute binary file: Exec format error 

I was basically following this tutorial, and I might know where’s problem, but now I can’t find out which one tutorial I followed up, because after I did everything it didn’t worked, so I tried another one. And I can’t really recall the exact path where I was creating those changes(in which directory). I just know that I was going into /exec/ and there were some other files that I made changes to with nano, I remember that I added something like $JAVA_HOME = . and then something. If someone can help, I’d be grateful

Please edit your question to include the outputs of commands file /usr/local/java/jdk-16/bin/java and uname -m . Why are you trying to install java by any other means than apt ?

2 Answers 2

I actually fixed this problem by doing following:

sudo update-alternatives --config java 

This command shows each installation of Java along with its installation path:

Output: There are 4 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode 2 /usr/lib/jvm/java-16-oracle/bin/java 1091 manual mode * 3 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode 4 /usr/local/java/jdk-16/bin/java 1 manual mode Press to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/lib/jvm/java-16-oracle/bin/java to provide /usr/bin/java (java) in manual mode 

I choosed 2nd one and copied the path to it then did following:

and inside that file added following:

JAVA_HOME="/usr/lib/jvm/java-16-oracle/bin/java " 

I reloaded file to apply previous commands:

and after running the java -version everything was okay.

Источник

Introduction

Reasons
There might be many reasons of this error such as
1. Java architecture
Architecture of your java binary is different from machine architecture. Example, java binary is 32 bit while your system is 64 bit.
You can check the architecture of java binary with below command

Its output is somewhat as

/usr/bin/java: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c0e68d88922d9aa1c102a8a25adcfce4f958e4f4…

Читайте также:  Linux чем занято устройство

The output shows that the architecture of the Java binary file is 64-bit. You can check if the installed system supports this architecture.
2. Install missing libraries
Java library has dependencies on other files. It might happen that some dependent libraries are missing on your system.
To check the dependencies of java library, use below command

The output of this command will show you the dependencies of java library as below

linux-vdso.so.1 => (0x00007fffa1f1a000)
libjli.so => /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/../lib/amd64/jli/libjli.so (0x00007f7b0f2a0000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7b0f0a5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7b0eddb000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7b0f4a8000)

If any of these libraries are missing on your system, you will get Exec format error .
Install them using the package manager for your Linux distribution.
For example, to install the libc6-i386 package on Ubuntu, you can use the following command:

$ sudo apt-get install libc6-i386

This command will install 32-bit version of the C library, which is required to execute 32-bit binary files on a 64-bit system.

3. Update java
You can reinstall or update the java runtime environment variable using below commands

$ sudo apt-get update $ sudo apt-get install default-jre

4. Check permission
Check if java binary file has execute permissions.
You can use the ls command to check the file permissions as below

$ ls -l /usr/bin/java -rw-r--r-x 1 root root 7867 Feb 10 2023 /usr/bin/java

This output shows that the user does not have execute permissions on java binary.
To provide execute permission, use chmod command as below

5. Check corrupted file
It may also happen that the java binary file is corrupted or damaged.
To ensure that it is not, use md5sum command to calculate the checksum of java binary as below

If the checksum does not match the expected value, the file may be corrupt and you may need to reinstall it.

6. Check for symbolic link
A symbolic link is like a short cut to the actual file.
It might happen that the java command is a symbolic link to the actual binary.
Ensure that it points to the correct location using below command

$ ls -l /usr/bin/java lrwxrwxrwx 1 root root 22 Feb 11 2023 /usr/bin/java -> /etc/alternatives/java $ ls -l /etc/alternatives/java lrwxrwxrwx 1 root root 73 Feb 11 2023 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

In this example, the java command is a symbolic link that points to the /etc/alternatives/java file, which in turn, is a symbolic link to the actual binary file.
If either of these links is broken or pointing to the wrong file, you may get the Exec format error message.

To correct the symbolic link and point it to the correct location, use below command

$ sudo ln -fs /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/bin/java

Here,
ln, deletes the old java symbolic link and creates a new one that points to the /usr/lib/jvm/java-11-openjdk-amd64/bin/java file,
-f, option is to overwrite the existing symbolic link, if it exists, and
-s option is to create a symbolic link, rather than a hard link.

Читайте также:  Linux mint install icons

Hope this article will resolve the bash: /usr/bin/java: cannot execute binary file: Exec format error .

Java Concepts

  • Instance variables
  • Create object in 5 ways
  • Constructors with example
  • Constructor chaining
  • Access specifiers/modifiers
  • public static void main
  • Reading user input in java
  • Abstract class
  • Abstract method
  • Interfaces
  • Method Overloading
  • Method Overriding
  • this keyword
  • static keyword
  • Arrays
  • 2d arrays
  • switch-case statement
  • Ternary operator
  • Enhanced for loop
  • continue statement
  • break statement
  • Exception handling
  • throw and throws
  • Java try-with-resources
  • NullPointerException
  • IllegalStateException java
  • Inner classes
  • Marker interface
  • Serialization and deserialization in java
  • Convert nanoseconds to seconds
  • Get current directory path in 4 ways
  • Comparator interface
  • GET/POST request with HttpClient
  • Set default java version on Mac OS
  • Install openjdk on Mac OS from tar file
  • Math.random()
  • BufferedReader class to read text file and user input
  • Immutable class in java
  • boolean in java
  • Java StringBuffer class
  • Java scanner class
  • AutoCloseable interface in java

Источник

Calling java from Bash: «Cannot execute binary file»

I’m getting this error when I try to run the script using build.sh in the MSYS environment under Windows (64-bit!):

./build.sh: ./build.sh: cannot execute binary file 

Whatever the problem is, it’s with the script itself and not the command in the script. What text editor did you save the script with, maybe it has lines ending in CR/LF instead of LF?

That’s a weird error message: build.sh is telling you it can’t run build.sh ? What’s the output of file build.sh ?

1 Answer 1

The file was encoded in UCS-2 Little Endian !
Changing the encoding to UTF-8 without BOM resolved the issue.

Msys copes with Windows line endings. Cygwin doesn’t. Neither copes with weird Windows formats that aren’t ASCII-based, such as UCS-2 or UTF-8 with a U+FEFF prepended (which Windows calls a BOM).

@Gilles I’ve just tried it using Cygwin: it doesn’t work — as you said! The problem is that PowerShell adds a CRLF EOL symbol at the end of the file. Here’s my question at SO if someone can help: stackoverflow.com/questions/13135808/…

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью
Adblock
detector