Reputation: 23
Disclaimer: I am NOT a Java developer.
I have a shell script that passes variables into my java program.
#!/bin/bash
$JAVA_HOME/javac -classpath $clp myjavaapp.java "$1" "$2" "$3"
When I run this script I get the following error:
javac: invalid flag: /public/rest/api/1.0/cycles/search?versionId=-1&projectId=10005
Usage: javac <options> <source files>
use -help for a list of possible options
Where /public/rest/api/1.0/cycles/search?versionId=-1&projectId=10005
is the value passed it at $3
.
Here is a sample of the contents of my myjavaapp.java
file:
package myjavaapp;
...
public class myjavaapp {
public static void main(String[] args) throws URISyntaxException, IllegalStateException, IOException {
...
String variable1 = args[0];
String variable2 = args[1];
String variable3 = variable2 + args[2];
...
}
}
What am I doing wrong? Am I using the arguments correctly?
Upvotes: 0
Views: 5116
Reputation: 131376
The problem is probably the value of the $clp
variable that is /public/rest/api/1.0/cycles/search?versionId=-1&projectId=10005
and that is not a valid option for javac
.
Check its value first.
Then, the passed arguments "$1" "$2" "$3"
makes no sense :
$JAVA_HOME/javac -classpath $clp myjavaapp.java "$1" "$2" "$3"
The javac
command is for compiling class(es), not for running applications.
You probably mixed it with the java
command that allows to run a executable class (application) and that accepts args.
Upvotes: 3