I want to be able to set properties and commands for my Java Swing app. Similar questions have either deferred to using shell scripts or remain unanswered. Looks like normally this is done in Cocoa. Does this mean I need to incorporate Cocoa into my project just to be able to command it through AppleScript? Currently, I cannot even do simple commands such as resizing windows (which I wrongly assumed would work out of the box).
Related
I'm using the 3dmod program of IMOD which is coded in Java (using Qt I think). For my project, I often need to open multiple .mrc files (3D reconstruct) as well as the model I've put on it using a command like the following:
3dmod -E 1U my_3d_object_part1.mrc my_model_part1.mod
After doing all the parts (around 5-10), I need to open all of them to compare.
Are there any ways to create a shell script to do this? Knowing that file names are almost identical, only the number 1 will have to change.
Note that the doc says "3dmod will accept some Qt options (such as -style)". I don't know what those options do or if they can control the window position at launch. I am hoping I could distribute my model windows across my screen to see them all at once.
I am concerned this may not be possible. Are there any ways to control the initial window position at opening?
Qt5 applications can set their initial size/position using the qwindowgeometry flag, like this:
./myApp -qwindowgeometry 640x480+50+50
EDIT:
On Qt4, and I think only if you're using X11, the flag is named -geometry.
I need to create a Java application which sends some input parameters to a python script and sends some output back to my java application.
I cannot run the script in my java code using jython Or similar things as the python scripts are build on demand and I may need to add new scripts every now and then. So this should not impact my java app.
My java application will be running on a container and based on a few condition check it might have to select 1 of the py scripts from suppose 100 scripts and run it. And again the condition later on may change and a different script has to run at that time
I went through many websites and tutorials on the net but did not find anything relevant.
Has someone tried anything similar?
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...
I have a Java program using AWT which I would like to run on a headless system. The display for the program does nothing other than display stats. When the program finishes, it exits. There is no user interaction on the display. The program creates an output file which I use in my build system.
Is there a way to get the Java program to run without an X11 display configured? Can I force Java to run the program without trying to display anything? I do not have access to the source code (it is just .jar file), so I can't make modifications to the source.
Any thoughts on how I could get this to work?
The underlying question here is how to run Java applications without an X server; providing a "fake" X server is only one option. In Java 1.4 and up, you can do the following:
java -Djava.awt.headless=true
This allows applications which use AWT to run on headless systems even without an X server.
Xvfb can do what you ask for. I've not used it myself, but here is a link to wikipedia: http://en.wikipedia.org/wiki/Xvfb
You can use a vncserver.
vncserver :1001
export DISPLAY=localhost:1001
java..
The added advantages is that you can actually view the gui
using vncserver 'just in case'
Could also run Xvnc in a low resolution and color depth.
As mentioned by Charles Duffy the traditional method is to tell Java to go headless.
Note that you can always mount the jar in Eclipse and use jad+jadclipse to see what it actually does, and perhaps even override a class if you need to by putting another class-file in "front" of it in the classpath.
A facility that might be relevant if the program uses Java2D is that newer Java versions use optimizations in the X11 server to render faster. This alone might be a reason to devote an X11 server attached to a high performance graphics card to your graphics processing.
I've used with great success in the past the PJA libraries, they don't seem to be maintained anymore, but then again, just just want to run...
I was able to get headless mode in OpenJFX with the command line arguments
-Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw
I'm developing a Mac App in Java that logs into any one of our client's databases. My users want to have several copies of this program running so they can log into a couple clients at the same time, rather than logging out and logging back in.
How can I allow a user to open several copies of my App at once?
I'm using Eclipse to develop, and Jarbundler to make the app.
Edit: More Importantly, is there a way to do so in the code base, rather than have my user do something funky on their system? I'd rather just give them a 'Open New Window' menu item, then have them typing things into the Terminal.
You've probably already gotten enough code that you don't want to hear this, but you should really not be starting up two instances of the same application. There's a reason that you're finding it so difficult and that's because Apple doesn't want you to do it.
The OSX way of doing this is to use the Cocoa Document-based Application template in XCode. Apple Documentation: choosing a project.
This is something users are very accustomed to, and it works just fine. FTP programs, IRC clients, and many other types already use different "document" windows to point to different servers or channels. There's nothing inherently different about pointing to different databases.
Depending on how much code you've written, and how your application is designed, this may be pretty much impossible to implement without starting over. Developers who are encountering this problem during design phase, however, should definitely take Apple's advice.
From the Terminal, I can run
open -n -a appName.app
Then from Applescript, I can run
tell application "Terminal"
activaate
do script "open -n -a appName.app"
end tell
Then from Java, I can execute that script. Then, I can stuff that Java code into an Action. Then, stuff that action into a menu item that says "Open New Window".
That's what I'm going with for the moment. Now I just need to get the appName.
From the Terminal (or in a script wrapper):
/Applications/TextEdit.app/Contents/MacOS/TextEdit &
Something like that should work for you.
To do this in Java:
String[] cmd = { "/bin/sh", "-c", "[shell commmand goes here]" };
Process p = Runtime.getRuntime().exec (cmd);
If you are developing it in swing, you should just be able to instantiate the top Frame to create a new window.