How can I control other applications using Java ?
I'm using the Mary Speech Synthesizer(Open source, Java). It can synthesize speech well , but it requires the text to be in a textbox in the application window itself and then a button to be clicked . For this project of mine
the text that needs to be realized is gonna be inbound from another java application . I need to know how I can place the text in the textbox and send a click to one of the buttons in the application .
I'm hoping to figure out a way to synthesize speech from a buffer later on but till then this seems like it's a way to get things working . Also , I'm pretty sure I'll be able to find other applications for this later on and this seems like a very interesting problem ..
Get the other application's API and call its methods accordingly.
If an application does not offer an API to interact with it, there is no simple solution to make it.
However, since the application is open source you can verify what type of licensing it has, and include a part of its source code in your Java application and call it properly.
I think your best option is to find a library that does the text synthesizing. Since controlling another java application required that java application to provide the necessary API for you to access it. As #Edmondo1984 told in his answer you can include the part of the code from the open source application(After checking the licence).
Related
I'm working on my academic project. It's called Cloud-IDE now I'm at initial stage where I'm making an web application which will accept code from user, compile it and output will be displayed to user in browser.
now suppose there are multiple people working on same code remotely, how can i provide something like one document(containing code) that will be displayed to all. anyone can contribute to it or at least view changes in real time.
I'm using ace-editor for code editor is there any way to provide collaborative work.
Server side: java servlet and stuff.
You could use Firebase.
Scratchpad uses this technique.
My problem is pretty simple i have an application written in java and i want to send commands to it ex ( click a button , send some key strokes , click a menu item ) from my application witch i will write in delphi. Is this concept even possible ?
I actually had to do this at the last place I worked, you can get around it with complex window events etc... as mentioned above but if you have access to the Java source simply write other access methods either that call a specific runtime that closes (i.e. trigger a public static void main(String[] args); via a native call or via the command line.
OR
Implement simple a simple message system between Java/Delphi over TCP/IP and send either XML or some simple string mappings (I think it took about an hour to set up Maps that could pass back and forth).
In my case we were simply handling reporting and talking to the database so it was pretty easy to work around without getting into a native call. Alternatively, there is(was) a port of the JNI for Delphi that worked pretty well with Delphi 7. I have no clue what runtime you're using but it might be an option.
Honestly, the TCP/IP method is probably the easiest. It doesn't take a lot to implement, it doesn't eat a lot of resources and it allows you to execute "myMenuItem.onClick()" pretty easily as a packet, you just have to expose the methods.
http://home.pacifier.com/~mmead/jni/delphi/
Well It depends on which Java GUI technology is used . If SWT or AWT is used , you can get handle of UI components, because these two toolkit uses native libararies.. On the other hand, if that java application GUI is created by beans of SWING, you can not get any handle. Because, swing toolkit is implemented by pure Java..
If the Java app can be modified, the Java Robot API (included in JRE 1.3 and newer) might be helpful. This would allow to control a Swing application which does not provide windows handles as Gursel wrote. Obviously there would be some IPC required, which could be implemented using sockets for example.
The short: YES, but depending on the Java application, it might be difficult and unreliable.
I'm not a Java guy so I don't know if this is the norm, but the one Java application I had to automate displayed a single dialog that only used 1 (one) window handle! It was made up of several edit boxes, buttons, what looked like combo-boxes, but those were not true Windows controls but widgets re-created by whatever GUI toolkit the original developer used. I wasn't able to use normal Windows messages to manipulate those because, as far as Windows was concerned, it was a single window.
Happily the only thing I had to do was click a single button. I used mouse_event to move the mouse over the expected area for the button and then again to click the button. It works, but manipulating input this way is both unreliable and fragile.
To clarify Daniel ChapmanĀ and mjnĀ comments, find below a code extract showing Delphi controlling a Java Swing UI component (TextField) contained in a Jframe based on NetBeans ClientEditor sample.
Please notice, that this example does not use the Java source code or use TCP, XML, Windowing events handling technics or IPC, it's just simply Delphi code calling some Java code.
procedure TForm1.Button1Click(Sender: TObject);
begin
FJFrame := Tjavax_swing_JFrame.Create('Client Editor');
FClientEditor := Tclienteditor_ClientEditor.Create;
FJFrame.GetContentPane().Add(FClientEditor);
FJFrame.Pack;
FJFrame.SetVisible(True);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
// Delphi setting a value in a Java Swing UI component
FclientEditor.FirstNameTextField.SetText('Delphi 1stName');
end;
The long type names are just as a matter of clarity for this example and can be shorter of course.Additionally there is no problem with JNI in this example.
Have you had a look at Java for Delphi?
It let's you call Java from Delphi exposing the Java types as Delphi types.
I'm creating a Win32 application that controls another application which is coded in Java using AWT components. I figured that if I can retrieve the main List of the application and cast it with the JLIB library I'd be able to read its content.
First of all, am I right or I won't be able to get the real content of the List ? If I'm right I'd like to know how to achieve this since I didn't found any good spy software for Java and Spy++ only show a SunAwtComponent. Which I presume in the container for the whole Java application.
I'm not expecting someone to tell me how to do the whole thing but only a couple of direction would be really great since I've been looking for that for a while now.
Thanks for the replies !!!
Quite likely the Java application actually uses Swing, not AWT. Swing draws its own widgets on top of a single AWTComponent, so the list widget that you see doesn't exist from Windows point of view.
I assume you cannot modify this Java application so that it can be controlled over some reasonable API (e.g. JMX or REST)?
You can try running the JVM with JPDA debugging interface enabled. You can then use JPDA APIs to change data structures and directly call methods on any object in that program. Finding the right ones to call will be hard, though.
See http://download.oracle.com/javase/6/docs/jdk/api/jpda/jdi/index.html
Although I've been programming for a few years I've only really dabbled in the web side of things, it's been more application based for computers up until now. I was wondering, in java for example, what library defined function or self defined function I would use to have a program launch a web browser to a certain site? Also as an extension to this how could I have it find a certain field in the website like a search box for instance (if it wasnt the current target of the cursor) and then populate it with a string and submit it to the server? (maybe this is a kind of find by ID scenario?!)
Also, is there a way to control whethere this is visible or not to the user. What I mean is, if I want to do something as a background task whilst the user carries on using the program, I will want the program to be submitting data to a webpage without the whole visual side of things that would interrupt the user?
This may be basic but like I say, I've never tried my hand at it so perhaps if someone could just provide some rough code outlines I'd really appreciate it.
Many thanks
I think Selenium might be what you are looking for.
Selenium allows you to start a Web browser, launch it to a certain website and interact with it. Also, there is a Java API (and a lot of other languages, by the way) allowing you to control the launched browser from a Java application.
There are some tweaking to do, but you can also launch Selenium in background, using a headless Web browser.
as i understand it you want to submit data to a server via the excisting webinterface?
in that case you need to find out how the URL for the request is build and then make a http-call using the corresponding URL
i advice reading this if it involves a POST submit
I want to make a help/instructions page for my Java program but I really don't want to have to go through and program all the frames and searching and such. Is there a package or program that I can just insert the data into and it will read it and create the dialog? I couldn't seem to find anything about it on Google.
It doesn't have to look like this at all but I like having the table of contents and the search at least.
alt text http://www.freeimagehosting.net/uploads/752f287397.png
Thanks
Java help system : https://javahelp.dev.java.net/
The windows help dialog you show is part of the Window Help subsystem. You could easily create a help file for that and launch it from your Java application, but it would be platform specific. If you want to implement cross-platform help functionality, you're probably going to have to implement it yourself, but you could probably do it simply by including a set of HTML resources and using an embedded lucene index to supply search functionalty.
Have you consider using a simple HTML based manual and/or website where all that information may be accessed through?
Pretty much like http://java.sun.com/javase/6/docs/ for instance where you have a main page and you can navigate the topics from there?
If that's a website ( rather than a local /doc directory ) you can have the extra benefit from having a full featured search engine index it for you.
See also: Google is the Help menu
After all, how many times do you use these help systems instead of searching the web?