Score:0

bash bad interpreter permission denied

us flag

I have a freshly installed Ubuntu 22.04.

I'm trying to execute a single-file java code

./SingleFileSource

I get the following error

bash: ./SingleFileSource: /usr/bin/java: bad interpreter: Permission denied

I tried

chmod +rwx SingleFileSource
chmod +rwx /usr/bin/java

also tried to execute it as root but I'm getting the same error

On my previous Ubuntu 20.04 I was able to execute the code and I don't remember if I ever had to set any permissions explicitly.

Any ideas?

TonyB avatar
za flag
The error message indicates bash is having a problem with the "shebang" in the script... i.e. the first line which indicates the command interpreter. Further, the message indicates you are trying to use /usr/bin/java.... [This Link](https://www.jetbrains.com/help/idea/shebang-scripts.html) indicates you should specify the path to the JDK... is /usr/bin/java the JDK?? If it is, then perhaps you should add the contents of SingleFileSource to your question.
Csisanyi avatar
us flag
Yes, my JDK is at ```usr/bin/java``` and the shebang is ```#!/usr/bin/java --source 17``` I'm not sure if the content matters, it's a simple class with a main method and some functions
Csisanyi avatar
us flag
@TonyB What is interesting, if I rename the file with .java, remove the shebang and run it like java SingleFileSource.java it executes.
Esther avatar
es flag
can you put output of `which java`? can you confirm that output is the same as `/usr/bin/java`? that doesn't sound right.
TonyB avatar
za flag
I'm not a Java maven, but the link I gave you shows and example that ends: "--source 11" Could that be the problem? And as @Esther requested, could you provide the output of "which java" and confirm that output is the same as "/usr/bin/java"
Csisanyi avatar
us flag
@Esther @TonyB Thanks! ```Which java``` solved the issue, usr/bin/java was not the correct path, I only had a copy of the jdk in usr/bin/java
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.