Reputation: 9501
I have a JAR file saved on my desktop, is there a way that I ca get python to pen this up, as if I was just clicking on the link from my desk top, I am very new to python and know this is a dumb question, but would help me out alot.
Upvotes: 0
Views: 400
Reputation: 8711
I'll assume you're using Windows (it seems that way from how you've presented the question).
To simulate double-clicking a file on Windows, use os.startfile
(available only on Windows):
os.startfile("path/to/myjarfile.jar")
This will do whatever your system is configured to do with files with a .jar
extension.
For a more complete answer on starting files on Windows see this answer.
Upvotes: 0
Reputation: 54302
Why do you want to execute it via Python?
In my Windows environment such .jar
file is executed by Java:
C:\jre7\bin\javaw.exe -jar "%1" %*
Of course your OS should be able to change such association to open .jar
with other program. On my Windows I can use local menu to open .jar
file with Java, Eclipse, Firefox or I can chose other program.
Upvotes: 2