This question already has an answer here:
How to use Java to move Windows windows around on screen?
(1 answer)
Closed 6 years ago.
I am wondering is it possible somehow to move another window on the screen to different location using Java ?
Example: I would like to move this window to the marked location.
Interfering with other programs is usually only allowed with superuser access (root). If you do not mind executing your program as root, there are possibilities, but they are certainly not cross-platform, so you would have to write a version for every OS around. I would not use java for such things.
Also, the answer about using the Windows API will not work, since you will not be able to get the window handle of a different process. Just check the documentation:
SetWindowPos Changes the size, position, and Z order of a child,
pop-up, or top-level window.
Java APIs will not help you out here.
Related
This question already has answers here:
Totally Confused with java.exe
(3 answers)
How is JNI_CreateJavaVM invoked when running a java app from the command line
(1 answer)
Closed 1 year ago.
My question is regarding the java executable, the one that you use to run a Java program and that on Linux it is found for example in /usr/bin/java.
I have been experimenting a bit as I want to look into how everything happens behind the scenes, like how does the bytecode gets loaded, how is the execution of the actual Java program starting and other details that may not be so straightforward.
Until now I have looked at the execution with strace and found that a new thread is created and that thread is the one on which the Java program actually gets executed (from another question that I posted). From what I understand the java executable is a launcher of some sort, but I do not understand all the operations that happen behind the scenes.
So, what exactly is the java executable and is there any place where I can find the source code for it (this would really help me)?
The primary source file for the launcher in the current development JDK can be found here: https://github.com/openjdk/jdk/blob/master/src/java.base/share/native/libjli/java.c
As you see, it's quite short and delegates most of the work to other pieces of code, but should be useful as a starting point.
If you want to see the source for other JDK versions (this is basically the main development repo for future Java versions), you need to look into the appropriate repository.
This question already has answers here:
Is it possible to run C source code from Java?
(4 answers)
Closed 7 years ago.
I want to make a Java app that uses the Razer Chroma SDK, but the Chroma SDK is in c++
Is there a way I can run c++ code from Java?
I must use Java for what I want to make.
I have almost no experience in c++, but I understand enough to get doing what I need.
EDIT:
This question is slightly different then others, because it is about a specific SDK, not about general c++ libraries. For this library I was able to use a simpler approach then learning to use things like JNI
You probably want to look into using JNI
The easiest way I found, and then one that doesn't require learning stuff like JNI:
Create a console application with commands that fire off what you need
In Java, launch the console application and redirect it's input and output streams so you can send it commands, and log it's output (see 12013910)
Have a command in the console application that you can pass a PID, and have the console application watch for when it closes, and then it will close itself. (This fixes having the console application not being closed if the Java application crashes and doesn't call the closing method(s))
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)
This question already has answers here:
How to detect if a graphical interface is supported?
(5 answers)
Closed 8 years ago.
Update: as marked duplicate, I just want to mention, this seems like a duplicate, but the answer to the other mentioned question is not completely correct. Instead refer to the accepted answer below.
isHeadless would return unexpected true in certain cases.
Its a bit weird situation, but recently I build a very simple java application which can be run in console/terminal mode or in JavaFX UI mode.
However, then while using it on a remote computer which doesn't have any display attached. I got an error that this JavaFX UI application can't be initiated on systems without display, which is pretty obvious.
To overcome this problem, I have been looking for a robust way of detecting if the system has any display attached and it can initiate a JavaFX application, which has to be a platform independent solution, since it could be Windows or Ubuntu/Linux or Mac system.
Structure of the application:
A Main console app, which depending on input arguments executes internally a console app or UI app.
So that, if any arguments given, run in console mode or if no arguments then run in UI mode.
This is where I want to detect if there is a display available from within my main console app, which then won't even try to run the UI app if display is missing.
Any idea how can we achieve this or suggestion in a proper direction would be great.
I think you could use java.awt.GraphicsEnvironment
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
which will return an array with all the available screens. If this array is empty, there is no monitor.
Edit: About using isHeadless(), you can look at How to determine if GraphicsEnvironment exists
This question already has answers here:
Writing Eclipse plugin to modify Editor Preferences
(3 answers)
Closed 8 years ago.
I am working on a Eclipse plugin and I want to change some settings for the user in able to be able to use the plugin correctly
I need to make some changes in the settings of Eclipse using the code instead
For example:
If I want to access Window-Open perspective-Debug
Instead of telling the user these steps, I want to make it in the code
Any help ?
You have to be more specific, otherwise you're only going to end up at http://www.eclipse.org/eclipse/platform-core/documents/user_settings/faq.html . Your example is a bad one since you shouldn't be changing the perspective without the user's consent. Even then, that's not a Preference, that's an API call: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IWorkbenchWindow.html#openPage(java.lang.String, org.eclipse.core.runtime.IAdaptable) .
Your plug-in should not require the user to be in any specific perspective. They should be free to arrange the editor and views any way they like.