Use a Java application as the Default Program for a particular file type?
The problem is that a JAR file is selected as the "default application". However, JAR files are normally not executable. That is, a JAR file is not a valid Windows application. It doesn't matter if the JAR extension itself has a default application associated with it, because the "Open verb" is not used recursively in other "Open verb" definitions.
Instead,
- Create a batch (".BAT") file (or small EXE wrapper) that calls
java
(orjavaw
, as appropriate) and use that executable wrapper as the "Open with" program. (This will have an annoying intermediate console window if using a batch file.) Or, - Modify the registry so that the "Open verb" for the extension launches the JAR through
java
(orjavaw
).
In the end, either form should look similar to: javaw -jar TheJarFile.jar "%1%"
. (Note that javaw
is an executable, while TheJarFile.jar
is not an executable.)
See java - the Java application launcher for how to use java/javaw.
May be because .text is not an executable file.
try using this..
Runtime.getRuntime().exec("cmd.exe /C file");
This will open your file with the default program.
Update: I got confused first, may be I didn't read your question properly. I thought your executing .text file directly from a Java code..
Runtime.getRuntime().exec("file.text");
//Gives error CreateProcess error=193, %1 is not a valid Win32 application
So I suggested opening it with cmd(as in answer).
But reading your scenario, it seems windows is unable to execute your jar itself.
To make your jar executable, try this..
java -jar yourjarfile.jar
....