Reputation: 541
I have a java GUI whose button click event opens a particular jsp page present on a local tomcat server. In order to open that particular web page we use firefox and that also we didn't directly run firefox we execute a script in java which in turn execute firefox and loads the page. I know it seems quite weird but its not my design decision these are orders I need to follow. This Code is already written by someone else just got one problem with it on a particular server.
For Simplicity I have copied button click function code and made a new java program out of it as below:
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ProcessExample {
public static void main(String[] args) {
String[] envp = {"DISPLAY=:0.0"};
Process p1 = null;
try {
p1 = Runtime.getRuntime().exec("/home/msatyam/test.sh", envp);
}
catch(IOException e)
{
e.printStackTrace();
}
BufferedReader input = new BufferedReader(new InputStreamReader(p1.getInputStream()));
try {
System.out.println(input.readLine());
} catch (IOException ex) {
Logger.getLogger(ProcessExample.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
The script that runs the firefox browser "test.sh" is as below:
#!/bin/bash
firefox "localhost"
So, the above java code with the above shell script works fine for most of the systems, but while testing the above code in one of our test server it fails and gives the following error on stdout:
*STDERR [ld.so.1: firefox-bin: fatal: libssl3.so: version 'NSS_3.12.6' not found (required by file /usr/lib/firefox/libxul.so)
ld.so.1: firefox-bin: fatal: libssl3.so: open failed: No such file or directory
ld.so.1: firefox-bin: fatal: relocation error: file /usr/lib/firefox/libxul.so: symbol SSL_NumImplementedCiphers: referenced symbol not found Killed*
When we saw the above error, we thought there is some problem with firefox on this server, but we were wrong because when we ran the same script from the terminal it worked like a charm.
Test Server is running on Solaris 10.
And also I double checked for libssl3.so in this server which is present under directory: /usr/lib/firefox
What could possibly be wrong as this shell script is working fine when run via terminal but doesn't work when run via above java code.
Upvotes: 0
Views: 223
Reputation: 123570
The problem is most likely that you are removing all system environment variables before executing firefox, and replacing them all with the single variable DISPLAY
.
You can run env -i DISPLAY=:0.0 /home/msatyam/test.sh
to simulate what you're doing in Java from the command line.
If this reproduces the problem, you should instead get all the system's environment variable (using System.getenv()
) and append DISPLAY=:0.0
to that list, and then run your script.
Upvotes: 1