Execute java GUI program from external website - java

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.

Related

Alternative to clipboard for sharing data between a web based application and legacy desktop application

I've been pondering over this problem most the afternoon and haven't yet found the most ideal solution so thought I would see what others think..
There is a legacy Win16 application that has to be modified (with the least effort) in order to communicate with a web based application.
The idea is such that in the Win16 app, the user will want to look up a specific code, so they'll click a button which will then launch the browser and allow them to navigate a specific set of pages until they find the result they desire, then they have the option of either pressing Select or Cancel.
Pressing Select should pass back a small string back to the app (around 10 characters) and close the browser. Cancel will likewise send a Cancel message back to the app and again close the browser window.
I can't see many choices available in implementation as the Win16 app is not able to call webservices, so I'm looking at using the clipboard, however that is not without problems.
I hope there's some other alternative I haven't thought of,
As always - all advice appreciated.
Thanks,

Java Applet Printing dialog won't go away

I have a simple java applet that retrieves an image from a server and prints it out. The only problem is that I get the following java security warning:
Researching on this site and all over the web, some people suggest that I sign the applet (I tried that to no avail) and others suggest that I Modify a local java security setting but that isn't feasible for my clients.
Not only do I get this warning at the start of my applet, but seemingly any time the code attempts to interact with the printer, the dialog re-appears. Also, note that there is no checkbox next to 'Always allow this applet to access the printer'. These symptoms show on any browser.
How do I get java to respect the users choice to allow it to send jobs to the printer?
You might use the JNLP API services in a sand-boxed applet in a plug-in 2 JRE. They will still prompt the user each first time they go to print, but should also put an 'always allow' check-box on the dialog (though it really only applies for that run). See a demo. of the PrintService.
See also the applet info. page that includes a link on the Next Generation in Applet Java Plug-in Technology which "..brings new abilities to applets: such as .. allowing embedded applets to gain full access to the services of Java Web Start."

Java applet to connect different users to a shared screen window

No, Im not asking for a full made program :) Im kind of new to Java as language so Im not familiar with java libraries at all and my experience is mostly about php, but I understand OOP well.
My scenario:
I want to build a Java applet to my website, by which different users can share a same screen window in which they can drag and drop things(images) to specific positions and when one does, it would update the screen to the others. Before connecting, user would choose to build a new screen or join other. If he wants to join other he would just enter some existing (random) screen id to connect to. If he wants to create a new one he would access this screen in which he would see the screen id to share with someone else. I dont care if two persons wants to drag and drop different item to same spot, it would then just use the one that came last.
Now that you understand what I want to build...
What I really just need is the skeleton structure of something like this. What parts I will need to build something like this? Libraries and such, where should I look for tutorials, Best practices, hierarchy, should I use tcp or udp? I just need something where to start from.
An applet is run in the system memory of each individual client. There are strict rules about what applets can and cannot do, and I am not sure whether or not applets would be allowed to make remote connections to other users. I would advice doing some google leg work on java applet security and seeing what you dig up.
Assuming this is possible:
In terms of architecture, I think you would want one person designated as the host create the game and run all the game logic, while the clients just receive information pertinent to graphics being displayed (location, size, texture, what have you) and sends back information about what the client is doing.
I did something like this as a school project in high school, but I was forced to sign the applet to make it do remote http connections. I would assume this is still the same case.
Hope that helps a little bit.

how can i make UI automation in java by which i can capture button or menu of any external application dynamically

I want to automate an external application, but I have several problems:
How can I recognize a button or other field of an external application in Java?
I use the Robot class in Java for making notepad automation where I open notepad, select file menu, and save or exit, etc.
The problem is, it needs X,Y coordinates for the mouse pointer to go to the proper location.
I want to make it more dynamic, i.e. it should recognize the file menu of a running notepad anywhere on the desktop.
How can this be done in Java? Is there any class in Java I can use to do this?
Thanks everyone to give me response, I want to be more specific i want to know how can i make ui automation by using any tool if it is not possible in java or using any api of java.automation tool must be freeware.....i am searching net for that i found AutoIt is like that.But if any one do this type of things please share his/her experiance means is it possible to do that in AutoIt or not possible if not then which tool do that kind of things.
It is easy to integrate Sikuli into a Java-application since it is written in Java. Sikuli uses image recognition to find elements visible on the screen like buttons and such. It is very easy to use and provides an alternative for tasks that are difficult to handle with static positioning, like finding moving windows and such.
Take a look at this: http://sikuli.org/docx/faq/030-java-dev.html
Hope this helps!
You should have a look at Sikuli. It takes as inputs images of the ui elements to select an area in the targeted app. It's a UI Automation Application
That's a bit difficult to install (at least on Debian/Ubuntu, where I tested it), as you'll need a recent version of OpenCV, a particular version of JXGrabKey but the quality of the program worth the trip. Good Luck
Java doesn't have an API to examine the UI of another application; that would be a very big security risk.
Which is why the Robot class can only record events (key presses, mouse movements and clicks) but not which UI element was involved in most cases.
It would be possible to do more if the external application was written in Java because then, you could analyze the objects in memory but for obvious reasons, this isn't possible for C++ or .NET applications.

Java invoke com.apple.loginitems

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

Categories

Resources