Open Browser window from Java program

后端 未结 5 2037
小蘑菇
小蘑菇 2021-01-12 21:44

Question

I have an application written in Java. It is designed to run on a Linux box standalone. I am trying to spawn a new firefox windo

5条回答
  •  粉色の甜心
    2021-01-12 22:23

    after having read the various answers and various comments(from questioner), here's what I would do

    1) try this java approach http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html

    ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
    Map env = pb.environment();
    env.put("VAR1", "myValue");
    env.remove("OTHERVAR");
    env.put("VAR2", env.get("VAR1") + "suffix");
    pb.directory("myDir");
    Process p = pb.start();
    

    see more about this class:

    http://java.sun.com/developer/JDCTechTips/2005/tt0727.html#2
    http://www.javabeat.net/tips/8-using-the-new-process-builder-class.html

    2) try doing this(launching firefox) from C/C++/ruby/python and see if that is succeeding.

    3) if all else fails, I would launch a shell program and that shell program would launch firefox!!

提交回复
热议问题