{"id":12,"date":"2007-03-18T16:16:21","date_gmt":"2007-03-18T21:16:21","guid":{"rendered":"http:\/\/wp.javatechniques.com\/blog\/linux-x11-libraries-for-headless-mode\/"},"modified":"2007-06-25T13:13:58","modified_gmt":"2007-06-25T18:13:58","slug":"linux-x11-libraries-for-headless-mode","status":"publish","type":"page","link":"http:\/\/javatechniques.com\/blog\/linux-x11-libraries-for-headless-mode\/","title":{"rendered":"Linux X11 Libraries for Headless Mode"},"content":{"rendered":"<p>Java 1.4 and higher include support for &#8220;headless&#8221; mode, allowing many AWT operations to be used on machines that do not have a keyboard, mouse, or display. Launching a virtual machine in headless mode is simple: Just specify the <CODE>java.awt.headless<\/CODE> property on the command line:<\/p>\n<p><PRE>java -Djava.awt.headless=true &#8230;<\/PRE><\/p>\n<p>Headless mode is useful, for example, for rendering images from servlets running on a dedicated server. More details on headless mode can be found on <A HREF=\"http:\/\/java.sun.com\/j2se\/1.4.1\/docs\/guide\/awt\/AWTChanges.html#headless\">Sun&#8217;s AWT Enhancements<\/A> page.<\/p>\n<p>Dedicated servers and virtual dedicated servers (or &#8220;virtual private servers&#8221;) are an increasingly affordable way to host java (and other) systems. While many dedicated server vendors offer Linux as an option, the default installations often lack X11 support. Fortunately, it is only necessary to install a subset of the X11 libraries to allow headless mode Java applications to function properly.<\/p>\n<p><center><br \/>\n<script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-6996704245138669\";\ngoogle_ad_width = 468;\ngoogle_ad_height = 60;\ngoogle_ad_format = \"468x60_as\";\ngoogle_ad_type = \"text\";\ngoogle_ad_channel = \"\";\ngoogle_color_border = \"663300\";\ngoogle_color_bg = \"330000\";\ngoogle_color_link = \"FFFFFF\";\ngoogle_color_text = \"AECCEB\";\ngoogle_color_url = \"AECCEB\";\n\/\/-->\n<\/script><br \/>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><br \/>\n<\/center><\/p>\n<p>The listing below shows the minimal set of libraries needed to use JDK 1.4.2 under RedHat Linux 9.0, tested on a virtual dedicated server. The files can simply be uploaded from a full RedHat installation (on the same architecture) to <CODE>\/usr\/X11R6\/lib<\/CODE>:<\/p>\n<p><HR><\/p>\n<pre>\r\n<font size=\"-1\">\r\n\r\nlrwxrwxrwx    1 root     root       13 Aug 30 20:44 libICE.so -> libICE.so.6.3\r\nlrwxrwxrwx    1 root     root       13 Aug 30 20:44 libICE.so.6 -> libICE.so.6.3\r\n-rwxr-xr-x    1 root     root    82080 Aug 30 20:44 libICE.so.6.3\r\nlrwxrwxrwx    1 root     root       12 Aug 30 20:43 libSM.so -> libSM.so.6.0\r\nlrwxrwxrwx    1 root     root       12 Aug 30 20:43 libSM.so.6 -> libSM.so.6.0\r\n-rwxr-xr-x    1 root     root    31544 Aug 30 20:42 libSM.so.6.0\r\nlrwxrwxrwx    1 root     root       13 Aug 30 20:40 libX11.so -> libX11.so.6.2\r\nlrwxrwxrwx    1 root     root       13 Aug 30 20:40 libX11.so.6 -> libX11.so.6.2\r\n-rwxr-xr-x    1 root     root   911288 Aug 30 20:40 libX11.so.6.2\r\nlrwxrwxrwx    1 root     root       14 Aug 30 20:28 libXext.so -> libXext.so.6.4\r\nlrwxrwxrwx    1 root     root       14 Aug 30 20:28 libXext.so.6 -> libXext.so.6.4\r\n-rwxr-xr-x    1 root     root    51632 Aug 30 20:28 libXext.so.6.4\r\nlrwxrwxrwx    1 root     root       12 Aug 30 20:28 libXp.so -> libXp.so.6.2\r\nlrwxrwxrwx    1 root     root       12 Aug 30 20:28 libXp.so.6 -> libXp.so.6.2\r\n-rwxr-xr-x    1 root     root    26788 Aug 30 20:28 libXp.so.6.2\r\nlrwxrwxrwx    1 root     root       12 Aug 30 20:29 libXt.so -> libXt.so.6.0\r\nlrwxrwxrwx    1 root     root       12 Aug 30 20:29 libXt.so.6 -> libXt.so.6.0\r\n-rwxr-xr-x    1 root     root   306428 Aug 30 20:28 libXt.so.6.0\r\nlrwxrwxrwx    1 root     root       14 Aug 30 20:37 libXtst.so -> libXtst.so.6.1\r\nlrwxrwxrwx    1 root     root       14 Aug 30 20:37 libXtst.so.6 -> libXtst.so.6.1\r\n-rwxr-xr-x    1 root     root    17712 Aug 30 20:35 libXtst.so.6.1\r\n<\/font>\r\n<\/pre>\n<p><HR><br \/>\n<CENTER>Figure 1. Listing of X11 libraries in <CODE>\/usr\/X11R6\/lib<\/CODE><\/CENTER><\/p>\n<p>Figure two shows an example of commands that can be used to transfer the files from a full installation to another server.<br \/>\n<HR><br \/>\nOn the full installation, build a tar archive of the libraries and transfer them to the remote server:<\/p>\n<pre>\r\n\r\ncsh> cd \/usr\/X11R6\/lib\r\ncsh> \/bin\/tar cvzf \/tmp\/x11-libs.tgz libICE.so libICE.so.6 libICE.so.6.3 \\\r\n    libSM.so libSM.so.6 libSM.so.6.0 libX11.so libX11.so.6 libX11.so.6.2 \\\r\n    libXext.so libXext.so.6 libXext.so.6.4 libXp.so \\\r\n    libXp.so.6 libXp.so.6.2 libXt.so libXt.so.6 libXt.so.6.0  \\\r\n    libXtst.so libXtst.so.6 libXtst.so.6.1\r\ncsh> scp \/tmp\/x11-libs.tgz server.domain.com:\/tmp\/\r\ncsh> rm \/tmp\/x11-libs.tgz\r\n<\/pre>\n<p>Then log into the remote server, use <CODE>su<\/CODE> to become root, and untar the archive:<\/p>\n<pre>\r\n\r\ncsh> su\r\ncsh# mkdir -p \/usr\/X11R6\/lib\r\ncsh# cd \/usr\/X11R6\/lib\r\ncsh# tar xvzf \/tmp\/x11-libs.tgz\r\ncsh# rm \/tmp\/x11-libs.tgz\r\n<\/pre>\n<p><HR><br \/>\n<CENTER>Figure 2. Transferring the libraries between machines<\/CENTER><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java 1.4 and higher include support for &#8220;headless&#8221; mode, allowing many AWT operations to be used on machines that do not have a keyboard, mouse, or display. Launching a virtual machine in headless mode is simple: Just specify the java.awt.headless property on the command line: java -Djava.awt.headless=true &#8230; Headless mode is useful, for example, for &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/javatechniques.com\/blog\/linux-x11-libraries-for-headless-mode\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Linux X11 Libraries for Headless Mode&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-12","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/pages\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":0,"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/pages\/12\/revisions"}],"wp:attachment":[{"href":"http:\/\/javatechniques.com\/blog\/wp-json\/wp\/v2\/media?parent=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}