Bash Shell function error: command not found

I am new to bash, so please bear with me if this is a stupid question:

What I really want to print in the shell is as follows:

javac -classpath "emarket.jar" Testclient.java -Xlint:unchecked

The fact is that if I manually draw the above line in bash, it will run without errors. However, if I create a custom function in .bashrc as follows:

function compile() { 'javac -classpath "emarket.jar" '$@'.java -Xlint:unchecked';}

And execute this command in bash:

compile Testclient

The error comes:

bash: javac -classpath "emarket.jar" Testclient.java -Xlint: unchecked: command not found

I believe that the compile () function in .bashrc should generate the same command in bash, but I really can't go through this, can anyone help me? Thank you very much in advance!

+3
2

, , $@

function compile() { 
  javac -classpath "emarket.jar" "$@".java -Xlint:unchecked;
}

. .

+8

' . ( , ). ,

+1

Source: https://habr.com/ru/post/1736250/


All Articles