Reputation: 27
I have the following code
public class MyClass {
public MyClass (String myString){
myFlag=myString
}
ProcessBuilder pb = new ProcessBuilder("Path to my application", "variousflags", myFlag)
Process p = pb.start();
}
When I run
myClass("worddocument.doc")
pb doesn’t start. In debugging MyClass, I noticed that:
myFlag ="worddocument.doc
without the final quote. For a flag to work in the ProcessBuilder, it has to within quotes. I have to include the line
myFlag= myFlag.concat(""");
which gives me the error message in Netbeans "unclosed string literal". How can get rid of the neatbeans error, or even better, how can I get the final quote back? Thanks
Upvotes: 0
Views: 139
Reputation: 27
The issue has disappeared now :-) It must have been a bug in netbeans or java... Unfortunately, I can't reproduce the issue, and I am not sure exactly when it fixed itself. If encountering the same problem, I would suggest: 1-restarting computer, 2-restarting Netbeans, 3-commenting out
myFlag= myFlag.concat("\"");
Upvotes: 0
Reputation: 329
stringFlag= stringFlag.concat(""");
will cause a problem since your ide thinks you close the String at the second quotation mark.
Try to escape the second quotation mark.
stringFlag= stringFlag.concat("\"");
Upvotes: 2