Starting my Java program for an event of the other - java

I have a desktop GUI program written in Java by a third party vendor. This program has a number of frames and controls on them. Now I have a requirement to start my Java program when the user clicks on a specific button on a specific frame of that Java program. Is that possible anyway? I am working on Windows 7 with JDK 7 u17.(There is a scripting language called AutoIt which provides this kind of functionality but I can not use it as it is reported as False-Positive virus by my anti-virus software, i.e. Quick Heal.) Thanks in advance.

Related

Java - headless mode - Raspberry Pi [duplicate]

This question already has an answer here:
Run Java AWT/Swing GUI app in headless server
(1 answer)
Closed 7 years ago.
I have a Java Application that runs on a Windows OS, desktop machine with a nice graphical user interface. I updated, modified etc. to get it running on a Raspberry Pi 2B. It just runs about fine. However you would notice that the GUI interface is a bit slow.
On top of that I now plan to run the application on the Raspberry Pi in an optimized mode, where I don't really need the GUI. I was checking many documents about "headless mode", however, I couldn't get a proper answer to my question:
If running my standard GUI application in headless mode, does it automatically take care, i.e. neglect all methods of updating the GUI components? or what needs to be done in order to avoid Exceptions etc.?
Will it theoretically boost performance?
or shall I simply avoid feeding data into tables etc. when running in a non GUI mode?
Best Regards
No, headless mode only means the JVM is stripped of the Gui libraries. You should not use any Gui functions, they are not "stubbed out", they would fail. It emulates only a few things which can be used off-screen (mostly needed for printing or charting)

Controlling mouse when Java window is out of focus

I'm interested in writing a program that will assist me in marking exam papers online. I would like to use the keyboard to control the mouse eg if I press '1' then the mouse will be sent to a specified location and click there. This will double my work output at least. The problem is marking is done through Internet Explorer so the Java program will be out of focus. From searching this site I found that someone has written a library that can receive keyboard input out of focus but I couldn't find any such thing for mice (I don't think Java Robot works out of focus).
Does anyone know whether such a program is possible in Java using standard libraries?
The problem of course is capturing key presses when Java is not in focus. You have three main options as far as I can tell:
Write your own JNA or JNI code to register your hot keys, or
Find a library that does this and call its methods, or
Use a scripting program like AutoIt (if this is Windows) that is linked to your Java program, such as with sockets linking the standard inputs and outputs of both programs.
I have used the 3rd option successfully, but in fact for me, it was usually easier just to do everything in AutoIt.
Note that this statement is not true:
(I don't think Java Robot works out of focus).
The Java Robot doesn't require that a GUI has focus, and in fact does not require that a GUI be running at all.

Launching a Java program via double click [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have a Java program that I have been working on. I would like to show it to my girlfriend, who would have no clue as to how to work with Java, and make it easy for her to do so. I understand the first step is to compile it to .class 's from the command line, but after that I am clueless.
I would be interested in finding out how to do this both for Windows and Mac OS (I am on a Mac, along with my girlfriend, but my school uses Windows computers).
I have been on Oracle and seen their demos, they download as .jnlp, is that a step in the right direction?
And specifically, I am looking for a "file" of some sort that is simply downloaded and launched, no terminal involved (maybe a file with a command line within?).
Launching a Java program via double click
..seen .. demos, they download as .jnlp, is that a step in the right direction?
The title and that quote typically represent two different ways to launch Java desktop apps.
"download as .jnlp" That is the 'deluxe' version, known as Java Web Start. It is a little trickier for the developer (you) but very easy for the user (your friend).
"Launching a Java program via double click" is more commonly associated with an executable Jar. (Although JWS also supports the 'double click' - but with menus and shortcuts.)
Either strategy will work on OS X, Windows or *nix, but the first has JRE versioning (making sure the end user has a JRE, and it is recent enough to run the code) assisted by scripts, and many other 'bells and whistles'.
Java Web Start
JWS apps. typically deployed from a web page or server accessible to the user machine, so your friend 'surfs on over' to the link you sent her to 'Download here'.
The moment she arrives at your web page, the deployJava.js will check her PC has a suitable minimum version of Java to run the app. If not, she will be guided through a process to get it.
When the JRE is confirmed (which happens invisibly for those with a later JRE) the script writes a link in the web page that by default is a button.
The user clicks the button and the JWS client (part of Java) will read the JNLP and begin to install the app.
If the app., requires permissions extended beyond the default sand-box, the user will be prompted as to whether to allow the code to run. See Appearance of Java Security dialog for more examples like:
If the user chooses Run ..
The app. will be loaded and appear on-screen (possibly along with desktop shortcuts and start menu being added).
To launch it the second and subsequent times, the user double clicks the desktop shortcut or activates the menu item. This is how Starzoom (which has an icon defined in the JNLP) appears in Windows 7.
Executable Jar
Another lesser alternative is an executable-jar.
It uses a manifest.mf in the Jar that specifies the main class.
While being a lesser experience for the end user, it is also simpler for the developer - a trade off that might come in handy for limited distribution.
Requires a suitable version JRE installed.
The user obtains the Jar from whatever source (USB, Bluetooth, web site etc.) and saves it anywhere on their machine that is convenient.
To launch it, the user double clicks the Jar.
You could create a bat script (Windows, I don't use OSX, but i think it's shell script for that) with the Java command you use to execute your Java program.
Or you could put you java class into a JAR file
Try NetBeans, make a project in there, and build your codes with it. It automatically produce jar file that can be execute via double click almost in any platform.

Java on Linux: maximize a non-Java GUI application

From Java code, is there a way to maximize the window of a different GUI application? I have access to Process objects created for these other programs, as well as a semi-reliable way to get their PIDs and a generic String indicating the name of the process binary (e.g. "firefox").
I can also programmatically execute full bash shell statements (including commands connected with pipes), if there's some command-line way of going about it.
On MS Windows, I recall seeing somewhere about a Java library that wraps the win32 windowing API, allowing one to pass those Windows-specific signals to applications - would there be something similar to that on a Linux setup? This is for a Red Hat system, if that matters.
Not in a "standards-based" way, no.
The X-Windows system is independent of specific window managers, as such, there is no standard way to "maximize" a window. It ultimately depends on the features of the window manager in use...

How to gain control on window based application in java

How can i gain control on window based appliaction in java.
I am not asking like world or Excel.
I am asking for a window based application, suppose a media player(not specific window media player) any media player that is running on window.
How would you control the windows based application if you took Java out of the equation?
Does the program provide a COM interface? There are a number of Java-COM
bridges.
Does the program provide a plug-in API? You could write the DLL in C/C++, then either use JNI/JNA to interact with the DLL from Java, or use some kind-of interprocess communications layer.
Do you have have some view in the to low level Win32 message pump of the program? Then perhaps you could create native DLL to send messages via SendMessage on behalf of the java program.
It really depends on what you expect to do with the program, and what the program provides. There is no built-in functionality allowing one program to control another program, especially from Java.

Categories