I saw a video tutorial about making a video player in javafx. In that tutorial the path to the video file was set in the program code itself. I searched a lot to find some tutorial to pass the path to the file at runtime by double clicking it, like, we always double click on a video file to open it in windows media player or any other similar program. All the file based programs I come across is setting the path in the code itself. How can I make my program to receive the path to the file at runtime or from the operating system? Can anyone suggest me a good tutorial
Related
My JavaFX program needs to compute a file name path for various user-written files such as the product-specific preferences. For example, "Do you want to open your previous file the next time the program starts" and so on. I have successfully experimented with https://github.com/dlemmermann/JPackageScriptFX and "jpackage" for Windows at least, so it looks like I will shortly need a way to code, in a cross-platform manner, the "correct" path in which to store such files.
Is there a standard API or coding technique that will give me a file path that the program can write using user permissions that is "correct" for these native platforms?
I am not aware of a single piece of software which would do that but I think my answer to this questions Java - Cross-platform filepath may be helpfull for you. It also mentions how the same can be achieved on Android for example.
I am developing Media Player in JavaFx and now I want that when I right click on any media (.mp4) file and open with my JAR file that it will start playing. How to get this function work?
I am not a pro in java, but in most programming languages when we open with something, the path is sent as argument.
In java maybe the parameter String[] argsin main method, which is an array, will contain the path to the file you opened with. Then you can use it to open the file.
You can test it easily by printing the array args, and opening the mp4 file with .exe or .jar(not sure)
At end sorry for the confusion but I am at this time unable to test as i am away from any jvm.
If you want it in android then you have to further view intents-filters here
https://developer.android.com/guide/components/intents-filters
I'm trying to make a program similar to Windows Photo Viewer, the program that pops up usually if you double-click an image in Windows. I've already made my own program, however it uses a JFileChooser associated with a button to bring up images to open inside the application itself (Windows photo app doesn't seem to do this).
Question:
How can I make my application handle certain file types when its double-clicked from Windows? My guess would be something along the lines of my main class having a Path/String type argument of the file I want to open, but I'm not sure how to exactly implement that.
What type does Windows pass to a program whenever we open a file? String?
Once my first question is fixed, is there anything special I would need to do to associate my program to image files (when making .exe file or installer)?
Include a java-web-start <association/> tag as a "hint to the JNLP client that it wishes to be registered with the operating system as the primary handler of certain extensions and a certain mime-type." Note that " the <offline-allowed/> element must also be included." A web server is not required and a platform-specific <shortcut/> is optional. The file to open will be a command line parameter.
I am using JNA with Java to find some properties about open windows on a Windows machine desktop. I am trying to find a way to get the file being accessed by an arbitrary windowed application. For instance, say I get information regarding the window of an open pdf document in adobe. I want to be able to get the filepath of the pdf document displayed in the window.
I know about the GetWindowModuleFileName() method, however this gets you the filepath of the executable of the application, i.e. 'javaw.exe'. If you have 'my.pdf' open in adobe, I'd like to get the filepath of this document, i.e. 'C:\...\my.pdf'.
I've done some searching around (on this site and others) and haven't found anything yet on this in particular.
thank you for your time, -Kevin
If you know the process ID, you can get the list of all files currently opened by the process using Handle utility. However, it depends if adobe reader continues to keep the file open or closes it after reading it completely.
I want to create my own file format for a particular kind of file. When someone downloads this file I want their system to know it should be opened with my application.
For example when I download a .doc file, my computer asks me whether I want to save the file or open it with Open Office. Similarly, If that .doc file is sitting on my desktop, and I double click it, it automatically opens with the correct application.
I believe this has to do with associating the file extension with the application in the context of the underlying OS.
Can any one point me to some good resources about how to do this in java?
Thanks.
Edit:
Sorry I want to clarify. Is there a way I can have my application associate the file type with itself when it is installed?
Edit:
found this...
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/jdic_assoc/
platform independent solution
This source shows how to make a file association in windows:
http://www.rgagnon.com/javadetails/java-0592.html
You will probably have to do it per installer that you make in each OS.
found this... http://java.sun.com/developer/technicalArticles/J2SE/Desktop/jdic_assoc/ platform independent solution