我安装好了JAVA怎么让程序自己寻找到安装到的路径?急求

解决方案 »

  1.   

    安装好了Java什么意思?jdk?
    如果说jdk路径的话,你可以送系统参数(如果有设javahome的环境变量)或者注册表中javasoft相关项读取
    如果你自己程序的安装路径,方法随你自己定了
      

  2.   

    比如说我安装到了E:某个文件下。然后怎么让JAVA自动找到这个安装的路径呢
      

  3.   

    呵呵,补充一些
    System.getProperties( "java.home");
    System.getProperties( "java.version");
    System.getProperties( "java.class.path");
    System.getProperties( "java.ibrary.path");
    System.getProperties( "os.name");
    System.getProperties( "user.country");
    System.getProperties( "user.home");
      

  4.   

    System.out.println(new File("").getAbsolutePath());
      

  5.   

    String path = System.getProperties("java.home");这个是对的
      

  6.   

    public class Test { /**
     * @param args
     */
    public static void main(String[] args) {
    System.getProperty("java.home");
    System.out.println(System.getProperty("java.home"));
    }
    }结果: 
    IWAV0055I Java Bean bb.Test 以 main 方法开始
    lxg
    D:\开发工具\Eclipse\jre
      

  7.   

    楼上的答案不对啊,我做了测试不是这个结果,是默认的系统使用的java运行时环境的路径
      

  8.   

    public   class   Test   { 
    public   static   void   main(String[]   args)   { 
    System.out.println(Test.class.getClassLoader().getResource("").getPath()); 


    这个因该可以