Eh??? I am not sure what you mean here??? Also, why would it relate to Java??? Could you please explain again about this??? Are you saying you are attempting to open a java file to see its source code? Or you want to run a java class?
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
I have a feeling that this is not a Java question... Anyway, have you tried to select 'other application' and choose it to run? I am not sure how Window passes the file as an argument to the Open With...
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
You could create a batch file that passes the first arg along as an arg to your program:
java -jar MyProgram.jar %1
If you select your batch file in the "Open with..." dialog, the filename will be passed as that argument %1.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
The %1 in my example above is the first parameter to the bat file, which in the case of "Open with..." it will be the full path of the file.
You are pass that as an arg to your Java program, so you can pick it up in the args array in main(String[] args) .>Why do you get the feeling that this is not a Java question?
Because it isn't really, it's an OS question.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
> How could I use this in Java though?
public static void main(String[] args) {
if (args.length > 0) {
String filePath = args[0];
}
}
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Yes, that is the entire point of the argument array to main(). If you execute your class/jar with the following statement
java MyProgram A B C
your args array in main() will contain {"A","B","C"}
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847