Reputation: 39750
Is it possible to specify which X display the JVM is to launch it's windows on through the JVM? I am thinking something like this
java -DISPLAY=THE_DISPLAY_I_WANT:0.1 -jar my.jar
I looked at the man pages and I can't find anything.
or do I need to wrap my call to the jvm in a shell script like this
#/bin/sh
export DISPLAY=THE_DISPLAY_I_WANT:0.1
java -jar my.jar
I don't want to make a script just to specify an argument that can be past directly to the JVM.
PS: No, I don't want to change my enviroment DISPLAY variable I want to launch the JVM on whichever DISPLAY I like :)
Update Responding to the question "Why does it matter if I use the second solution" Using the second solution, If I would like to start a jvm session on several different displays I would have to set the DISPLAY for each session.
What I am looking for is like what you can do with Xprograms
try xterm -display my_display:0.0
So my question is can I do this with the jvm, I can't see it documented anywhere. If it can't be done then the correct answer should be "No you can't", I already know the alternative :)
Thanks
Upvotes: 0
Views: 1009
Reputation: 30014
Given your constraints on the answer, the answer you're looking for is "It can't be done"
I'm still curious why the second solution doesn't work for you. I realize it's not what you want to do, I just want to know why
Upvotes: 4
Reputation: 163267
If you'd be content with your suggestion,
java -DISPLAY=THE_DISPLAY_I_WANT:0.1 -jar my.jar
then I'm not sure why you resist either of these:
DISPLAY=THE_DISPLAY_I_WANT:0.1 java -jar my.jar env DISPLAY=THE_DISPLAY_I_WANT:0.1 java -jar my.jar
They don't modify the environment variable globally, if that's what you're concerned about. They only modify it for the new process (and whatever else it spawns). Other new processes will not be affected, and processes that were already running certainly won't be affected.
If that's not the issue, then I guess what you mean is that in the first example, you wouldn't really be modifying the DISPLAY
environment variable, not even for the new Java process. You'd instead be counting on the X11 layer of the current JVM to have some other way of determining where to send its graphical output. I suppose it could work that way. Maybe every other Java program on Earth just ignores that other way and lets the JVM fall back to using the environment variable instead, as it works for non-Java programs.
But why does it matter? It's not as though your program is going to use the (unmodified) DISPLAY
environment variable for something else, is it? Since it's not being used for anything else, you may as well just use it for its intended purpose, no?
Upvotes: 0
Reputation: 533492
If you are using sh, bash or the like you can just do
DISPLAY=THE_DISPLAY_I_WANT:0.1 java -jar my.jar
Upvotes: 0