-1

This is my bash script ("compile_java.sh"):

#!/bin/bash
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
echo "$1"
echo "$filename"
echo "$extension"
docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp openjdk:15 javac $1

And that is my try to call the bash script (i'm using Ubuntu): . compile_java.sh TestJava.java

And that is the "error" message:

TestJava.java
TestJava
java
error: invalid flag: TestJava.java
Usage: javac <options> <source files>
use --help for a list of possible options

Can someone give me a hint please?

  • you need to set java path – Digvijay S Oct 19 '20 at 10:48
  • Check https://stackoverflow.com/questions/20587840/javac-file-not-found-first-java-usage-javac-options-source-files – Digvijay S Oct 19 '20 at 10:49
  • @DigvijayS that isn't working for me: `export JAVA_HOME=/usr/lib/jvm/openjdk-15-jdk export PATH=$PATH:$JAVA_HOME/bin docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp openjdk:15 javac $1` – CyborgBeta Oct 19 '20 at 11:12

1 Answers1

-1

Sorry, there was special characters in the bash file. This works fine:

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp openjdk:15 javac $1