I making an app in Java. I want an Open With Dialog to appear when a JButton is clicked.
I know that in Windows, the contents of the Recommended Programs list are determined from the registry entry
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\filetype\OpenWithList
..where 'filetype' is the required file type.
Is there any way that this can be done with complete independence of the OS in which this app runs? Or do I have to get the OS name and program accordingly?
Not completely sure whether this answer will be relevant as I am making some assumptions. In case it is a file you want to open, you can use Desktop#open which will open the File with the default application.
I assume (but did not test) that when no default application is set, a dialog will be shown asking what application you want to use to open that file (similar as when you double click such a file in your file browser).
This is not completely what you asked for, but might be sufficient.
Otherwise I am afraid I agree with Andrew's answer that there is no general way to do this.
Is there any way that this can be done with complete independence of the OS in which this app runs?
No.
Or do I have to get the OS name and program accordingly?
Yes.
Related
I made an application in java which locks files and changes their extension as .LOCKED
what i am asking is :
1- how do i make the windows recognizes that extension to be opened by that application by default ( not asking for the manual way .. i need an automatic way like when the program gets installed )
2- how do i make the program handle the .LOCKED extension when it gets opened ( now it only works when you select the file from inside the application )
I`m not sure if I understood all you need to do.
For the first question, tho, there is a simple way to solve that problem. You need to right click the file you want to open, and point to the app you choose to be opened with. I think windows will remember in the future your choice.
For second and third questions you should be more explicit than that.
I have a javacard and it has 2 applets installed. Now I would like to select one among the two. Currently how I do is that, I provide the cap file of the applet from which I get its AID. But I don't find this method satisfactory. So
Is there a way or steps to get the AID of the applets installed in a java card without having the cap file?
Is there a way to select the applet without its AID? By this I mean that is there a way to make an applet auto selectable after reset?
Are there any other ideas or insights over this?
For the questions you have asked,
Yes. PyApduTool can make you reach you goal. This tool can help you get all the packages' or applets'AID in java card even though you don NOT have the cap file.
Just press the "Refresh" button. the things you need appears in the right text field.
You can set you applet as "Default Selected" when installing it.
In this way, you can make you applet selected by default without having to know its AID.
For convenience, it should be better to know the applet-AID.
Only one applet can be the default selected.
The answer from Andy is good but i feel that its missing an important part of the question:
Javacard get applet AID of installed applets through Java code
If the question refers to finding installedf Applets from the code of one java card applet itself than this answer might apply:
First, it is possible to get the AID of the applet itself by JCSystem.getAID().
Second, it is not possible to "detect" other applets from within an installed applet.
Although if you know the other applet's AID you can get a hack of useful information about it using JCSystem and GPSystem.
So apart from inside JavaCard code, the Card Manager is able to list of installed applets with all their privileges and so on. You can use a tool of your choice. If you are working with JCOP, I recommend JCOP Shell. If you work with freeware I recommend Global Platform Pro from Martin Paljak.
Beside selecting AIDs and default selection there is no direct way to select an applet. There is an indirect way by using the SharedObjectInterface mechanism from JavaCard which lets you change control flow to a different applet.
maybe what I'm asking is difficult to do or even ridiculous, but I'll give it a try anyway.
I have a typical PHP website, with a products list. And I have a Java application which manages the products (CRUD). In that application I have a JDialog that pops up when I select to edit a product.
My question is: ¿Is there a way, no matter how difficult to implement, in which I click an "Edit product" button on the webpage and the java application JDialog pops up to edit that product?
Thank you.
I'm no expert on the matter but take a look at custom protocol handlers.
Define a custom protocol myapp:\\ that you can use on your web page in hrefs like:
Open Product 1
Then on OS level you need to specify how this protocol should be handled. (In your case that will be to run your Java program with the correct arguments to open product1). The installation of your Java program should make the necessary changes to the OS in order to correctly handle this custom protocol.
Take a look at this site for more information.
First of all, I'm a java developer and I am currently working on a small application for Windows only.
In my application, I wish to do as dropbox or tortoise do : add an overlay icon in windows explorer to show the user some state of files managed by my application. (I want the icon of the file change depending on some data stored in the file)
Is it possible to do so in Java ? Do you have examples ?
If it is doable but not efficient, how would you do instead ?
Thanks in advance
Fluminis
It would be possible to do this via JNI - you would need to hook into the Windows registry and from there into the Explorer shell, probably into the various file classes held there.
However, unless you have at least some familiarity with C++ and the windows API, you are unlikely to be able to achieve this.
Java is not the ideal language for what you want to do.
I'm trying to add my Java Application to the "Login Items" preferences pane that appears in OSX. This pane is visible if you go to System Preferences --> Accounts, and click on your account name. You should then see a "Login Items" of programs that will automatically open when you log in.
I know I can add my program using launchd, or LaunchServices, but I had a few users ask if it could display inside the "Login Items" window. In order to do this, I believe I need to modify com.apple.loginitems.plist, but the file is written in binary so it can't be readily accessed. I've looked at it using
defaults read com.apple.loginitems
and I've tried writing to it using
defaults write com.apple.loginitems key value
but it looks like the loginitems plist is quite complex and has a weird structure. I'm wondering if there's any proper way to do this using Java. I believe there used to be a Cocoa Java extension that let you do this, but I don't think that's possible anymore in Snow Leopard.
Hopefully someone can give me a hand here :-)
I actually just ended up writing a (very) short Cocoa console application in XCode using http://github.com/carpeaqua/Shared-File-List-Example/blob/master/Controller.m as an example