Sponsored Content
Top Forums Programming launching browser from Java on headless sever Post 302266176 by Solerous on Tuesday 9th of December 2008 04:27:25 PM
Old 12-09-2008
Ok, I'm convinced that this is some sort of configuration problem. I can get the browser to launch when written as a simple java program compiled at the command line:

Code:
import java.util.*;
import java.io.*;

public class Launcher {

        public static void main(String args[]) throws IOException {

                 String url = "http://www.ebay.com";
                 String[] commands = {"/bin/sh", "-c", "/opt/sfw/bin/firefox ", url, "-width", "1600", "-height", "1200", ":5"};

                ProcessBuilder pb = new ProcessBuilder(commands);
                Map<String, String> env = pb.environment();

                env.put( "DISPLAY", ":5" );
                Iterator it = env.entrySet().iterator();
                while (it.hasNext()) {
                        Map.Entry pairs = (Map.Entry)it.next();
                        System.out.println("\t>> environ:  "+pairs.getKey() + " = " + pairs.getValue());
                     }

Process process = pb.start();

        }

}

The output is just to show the environment variables and it looks like this:


>> environ: XFILESEARCHPATH = /usr/dt/app-defaults/%L/Dt
>> environ: LANG = C
>> environ: DISPLAY = :5
>> environ: ORACLE_BASE = /oracle
>> environ: ORACLE_TERM = vt100
>> environ: PWD = /usr/local/u00/de8
>> environ: _ = /usr/bin/java
>> environ: MAGICK_HOME = /usr/ImageMagicK/ImageMagick-6.4.4
>> environ: ORACLE_SID = cots
>> environ: USER = de8
>> environ: NLSPATH = /usr/dt/lib/nls/msg/%L/%N.cat
>> environ: EDITOR = /bin/vi
>> environ: MOZILLA_SOLARIS_PATCHCHECKER = disable_patchchecker
>> environ: HOME = /u00/de8
>> environ: SSH_CONNECTION = 128.219.196.118 64994 160.91.230.33 22
>> environ: LD_LIBRARY_PATH = /usr/jdk/instances/jdk1.5.0/jre/lib/sparc/server:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc:/usr/jdk/instances/jdk1.5.0/jre/../lib/sparc:/opt/SUNWspro/lib:/usr/openwin/lib:/usr/dt/lib:/usr/ImageMagicK/ImageMagick-6.4.4/lib::/oracle/product/9.2.0/lib
>> environ: LOGNAME = de8
>> environ: SHELL = /bin/ksh
>> environ: ORACLE_HOME = /oracle/product/10.1.3.2.0/OracleAS_1
>> environ: SSH_TTY = /dev/pts/1
>> environ: MAILMSG = [YOU HAVE NEW MAIL]
>> environ: MANPATH = /usr/opt/SUNWmd/man:/usr/man:/usr/local/man:/usr/share/man:
>> environ: NNTPSERVER = time.ornl.gov
>> environ: SSH_CLIENT = 128.219.196.118 64994 22
>> environ: MAIL = /var/mail/de8
>> environ: TZ = US/Eastern
>> environ: PS1 = ${PWD###/} $
>> environ: TERM = vt100
>> environ: PATH = /oracle/product/10.1.3.2.0/OracleAS_1:/oracle/product/10.1.3.2.0/OracleAS_1/OPatch:/usr/xpg4/bin:/usr/ccs/bin:/usr/local/bin:/usr/bin:/usr/ucb:/etc:/usr/sbin:/u00/de8/bin:/opt/NSCPcom:/sbin:/usr/local/etc:/usr/lib:/usr/opt/SUNWmd/sbin:/usr/bin:/usr/local/bin/perl5.00502:/usr/openwin/bin:/opt/sfw/bin:/usr/ImageMagicK/ImageMagick-6.4.4/bin:.:/oracle/product/9.2.0/bin

I decided to output the env vars in hopes that it would show what needs to be reset. But if I use the *exact* same code in my deployment, it fails and I get the following env settings:

08/12/09 14:14:27 >> environ: XFILESEARCHPATH = /usr/dt/app-defaults/%L/Dt
08/12/09 14:14:27 >> environ: LANG = C
08/12/09 14:14:27 >> environ: DISPLAY = :5
08/12/09 14:14:27 >> environ: ORACLE_CONFIG_HOME = /oracle/product/10.1.3.2.0/OracleAS_1
08/12/09 14:14:27 >> environ: NLSPATH = /usr/dt/lib/nls/msg/%L/%N.cat
08/12/09 14:14:27 >> environ: TMP = /tmp
08/12/09 14:14:27 >> environ: TZ = US/Eastern
08/12/09 14:14:27 >> environ: NLS_LANG = AMERICAN_AMERICA.WE8MSWIN1252
08/12/09 14:14:27 >> environ: ORA_NLS33 = /oracle/product/10.1.3.2.0/OracleAS_1/ocommon/nls/admin/data
08/12/09 14:14:27 >> environ: LD_LIBRARY_PATH = /usr/local/src/oracle/product/10.1.3.2.0/OracleAS_1/jdk/jre/lib/sparc/server:/usr/local/src/oracle/product/10.1.3.2.0/OracleAS_1/jdk/jre/lib/sparc:/usr/local/src/oracle/product/10.1.3.2.0/OracleAS_1/jdk/jre/../lib/sparc:/oracle/product/10.1.3.2.0/OracleAS_1/opmn/lib:/oracle/product/10.1.3.2.0/OracleAS_1/lib32
08/12/09 14:14:27 >> environ: X_LD_LIBRARY_PATH_64 = /oracle/product/10.1.3.2.0/OracleAS_1/lib
08/12/09 14:14:27 >> environ: ORACLE_HOME = /oracle/product/10.1.3.2.0/OracleAS_1
08/12/09 14:14:27 >> environ: SHELL = /bin/bash

Does anyone know how I can get the deployed version (running in the server container) to work exactly in the same way as the version run from a simple command line?
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running a script on a different Sever

Guys, I want to run a script located on a different server from my pc. Let say the server has an IP of 1.1.10.2/16 and the script path is: /home/user/bin/check.sh The script scans for all available devices on the lan. My pc has an IP of 1.1.15.4/16 and I can ping the sever and can... (3 Replies)
Discussion started by: tony3101
3 Replies

2. AIX

find the IP's on the sever

Hi , I am working on AIx server which is connected to another network which is a stock market via leased line , From my side I connect to the server locally but what i need is to know the ip whic the server connect to the stock market how I can Know this ???? Thanks (1 Reply)
Discussion started by: habuzahra
1 Replies

3. UNIX and Linux Applications

Exceptions while running application on headless linux

I want to install executable file(Demo.bin) on vMA4.0 virtual machine using ssh. Same can be installed on all other Linux/Unix box. but when I am trying to run it on vMA,I am getting the following error-- Could you please advise me how to approch this problem and how to resolve it? (4 Replies)
Discussion started by: smartgupta
4 Replies

4. Ubuntu

The best distro to use on enviorment headless and only run scripts

Hello, I pretend create a machine headless for only run scripts! I think use Ubuntu Server, but this is the best option? Exist another system more light? Because the purpose is run script which do mathematical calculations. Sum, Division and Modules! My knowledge about word gnu/linux is on... (0 Replies)
Discussion started by: enodev
0 Replies

5. UNIX for Beginners Questions & Answers

Resolution Won't Change on Headless Linux Box?

Hello All, Wasn't sure if I was supposed to post this under Hardware so posting here... Device: CuBox-i OS: OpenSuSE 13.1 Uname: Linux CuBox-PC 3.14.14-cubox-i #1 SMP Sat Sep 13 03:48:24 UTC 2014 armv7l armv7l armv7l GNU/Linux Window Manager: XFCE Display Manager: lightdm (*XDM?) I... (2 Replies)
Discussion started by: mrm5102
2 Replies

6. UNIX for Advanced & Expert Users

LAMP Sever

How do I install a LAMP server on a new installation of Debian 9 using the lalest versions of AMP? Here is what I have. Corrections please. MYSQL apt-get install mysql-server mysql-client You can verify the MySQL server status using command: systemctl status mysql ------- PHP7... (0 Replies)
Discussion started by: Meow613
0 Replies
All times are GMT -4. The time now is 03:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy