I noticed that Java proposes different look and feel classes for root and non-root users. I am trying to understand how to make LAF consistent. Moreover, it's inconsistent even within a user/root: depends on how user/root logged in:
Sample code (compiled and packaged in laf.jar
):
import javax.swing.UIManager;
public class laf {
public static void main(java.lang.String[] args) {
try {
System.out.print(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
}
}
Scenario 1 Logs in to machine (in GUI mode) as a regular user
Sample output (as user)
[xxx@yyy Downloads]$ java -classpath laf.jar laf
com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Sample output (switch to root via su
)
[root@yyy Downloads]# java -classpath ./laf.jar laf
javax.swing.plaf.metal.MetalLookAndFeel
Scenario 2 Logs in to machine (in GUI mode) as root
Sample output (as root)
[root@yyy Downloads]# java -classpath ./laf.jar laf
com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Scenario 3 Logs in to machine via SSH as a regular user (similar as scenario #1 above, but in this case - same LAF)
Sample output (as user)
[xxx@yyy Downloads]$ java -classpath laf.jar laf
javax.swing.plaf.metal.MetalLookAndFeel
Sample output (switch to root)
[root@yyy Downloads]# java -classpath ./laf.jar laf
javax.swing.plaf.metal.MetalLookAndFeel
Software versions:
[root@yyy Downloads]# java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build pxa6470sr9fp10-20150708_01(SR9 FP10))
IBM J9 VM (build 2.6, JRE 1.7.0 Linux amd64-64 Compressed References 20150701_255667 (JIT enabled, AOT enabled)
J9VM - R26_Java726_SR9_20150701_0050_B255667
JIT - tr.r11_20150626_95120.01
GC - R26_Java726_SR9_20150701_0050_B255667_CMPRSS
J9CL - 20150701_255667)
JCL - 20150628_01 based on Oracle jdk7u85-b15
[root@yyy Downloads]# cat /etc/redhat-release
Red Hat Enterprise Linux Workstation release 6.7 (Santiago)
env
for different scenarios, or in Java, use the result ofSystem.getenv()
. – BasketballGNOME_DESKTOP_SESSION_ID
in your environment? – OxendineUIManager.getCrossPlatformLookAndFeelClassName()
. – Disc