Open file with java application - java

I am using Ubuntu. I would like to have a user be able to double-click (or whatever they have set to open a file) on the save file for a java game i'm making, and have the game start and automatically load the save. How could I make the game launch instead of opening the file, and then pass the save's file name or location as an argument? Would i have to have the game create a new mime type the first time it ran, or something similar, so that Ubuntu knows what to do with the save when the user tries to open it?

Related

how can I get the parameter passed from the OS to the application and then use it

I have developed my java application and deployed it.
I want it to detect when i double click a music file eg .mp4, .mp3 and others to open play.
I have already set it as my default but it just opens the app, it cannot pick the path of the file.
Colleagues, how do I get that file path and use it when it is called?
Thanks a lot.

Java download file from URL with unknown filename

I have URL that gets called from my java app that returns the save/open dialog for an Excel file.
At the moment, it opens in a new tab but I want to return the dialog box in the same window. I do not know the file name as it is dynamic and changes based on the parameters passed in.
I also do not want to save it somewhere as I want the user to have the choice of opening or saving.
Is there anyway of doing this in Java? I've only seen examples where the file name is known.
EDIT
The URL is hitting a CGI Script
Create a File object in your app from the url, store it in a temporary location then ask Excel to open it for you.

Are there special permissions in Windows 7 to prevent file creation?

I created a program that takes in an excel file and pastes in an image of a graphical timeline based on the events in the document. But when trying this on a PC with windows 7 coming from XP and Vista I was unsuccessful in even creating the image. Is there a permission in Windows 7 that disallows a java program called by an excel macro to create files?
Formally it's a 1004 unable to get insert property of image file, but this only occurs because the file is not created in the first place.
An application is not allowed to write under Program Files unless it's run elevated (and you don't want it to run elevated.) Write to a per-user location instead, either AppData if the user should never need to see the files, or under the user's Documents if they might (eg an export that they are supposed to upload or mail.)

How can I determine the way to access certain third-party programs and resources from my Java app?

I'm trying to open a PDF file after I generate a report. I mean, the user logs in (it's a Swing-based app) and clicks to generate a report. Then, a PDF file is generated. I would like to launch the PDF reader at that moment. I could do something like exec("evince "+path_to_pdf_file). It's just for Ubuntu, Windows would be more difficult. I'm thinking I need to explore the registry.
How can I achieve this?
What you need is the method java.awt.Desktop#open
Launches the associated application to open the file.
If the specified file is a directory, the file manager of the current platform is launched to open it.

Open an external program in Qt with an attached file extension

I am making a qt application which allows the user to select a file and then upon clicking ok, start the associated program with the file already loaded. The program I want to start is java based, and I know how to use QProcess to get it to open, I don't know however how to add the file extension which the user is selecting. Any suggestions?
Did you try QDesktopServices::openUrl() ?
You can pass your program path and name as an Url (file:///) and it will be openned with a suitable application.
Sorry for leaving everyone hanging on this one, I actually solved this issue myself. Basically I just used QFileDialog to select my file I wanted to open and created a QString which was the entire command line I needed to use to get my application to run properly, which I opened via QProcess. Thanks for the help anyways.

Categories

Resources