sorry,回错了,这个是api
不知道java里的方法

解决方案 »

  1.   

    System.setproperty(...)
    System.getproperty(...)
      

  2.   

    启动dos窗口,输入set,回车就可以看系统的变量设置了。
      

  3.   

    呵呵掉调用命令啊可惜不是跨平台的
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;public class GetClassPath extends JFrame {
        JTextPane txt;
        BufferedReader br;    public GetClassPath() throws Exception {
            super("GetClassPath");
            setSize(300, 300);        addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent ew) {
                    System.exit(0);
                }
            });
            Container p = getContentPane();
            p.setLayout(new BorderLayout());
            JPanel p1 = new JPanel();
            p1.setLayout(new FlowLayout());        txt = new JTextPane();
            JButton getButton = new JButton("Get");
            JButton clearButton = new JButton("Clear");
            JButton cancelButton = new JButton("Cancel");        ActionListener action = new ActionListener() {
                public void actionPerformed(ActionEvent ea) {
                    if (ea.getActionCommand().equals("Get")) {
                        try{
                        getClassPath();
                        describe();
                        }catch(Exception e){
                        }                }
                    if (ea.getActionCommand() == "Clear") {
                        try{
                        clear();
                        }catch(Exception e){
                        }
                    }
                    if (ea.getActionCommand() == "Cancel") {
                        try{
                        describe();
                        }catch(Exception e){
                        }
                        System.exit(0);
                    }
                }
            };
            cancelButton.addActionListener(action);
            clearButton.addActionListener(action);
            cancelButton.addActionListener(action);
            p1.add(getButton);
            p1.add(clearButton);
            p1.add(cancelButton);        JScrollPane js = new JScrollPane(txt);
            p.add(js, BorderLayout.CENTER);
            p.add(p1, BorderLayout.SOUTH);        setVisible(true);
        }    public void getClassPath() {
            try {
                Process pr = Runtime.getRuntime().exec("cmd.exe /c echo %LASSPATH%");
                BufferedReader br = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                String myvar = br.readLine();
                txt.setText(myvar);
            } catch (Exception e) {
                txt.setText(e.getLocalizedMessage());
            }
        }    public void clear() throws Exception {
            txt.setText("");
        }    public void describe() throws Exception{
            br.close();    }    public static void main(String args[])throws Exception {
            GetClassPath gp = new GetClassPath();    }}
      

  4.   

    System.setproperty("TOMCAT_HOME")
    System.getproperty(TOMCAT_HOME)
      

  5.   

    谢谢楼上的大虾!问题搞定了!:)
    小生贪心地再多问一句exec方法中参数的写法在哪能够查得到阿?
    另外不跨平台此话从何说起?是因为exec中调用的方法吗?
    先谢了谢了。
      

  6.   

    呵呵那个参数其实就是一些WINDOW下的命令
    呵呵
    多看看文档就知道了 
    因为他只用在WINDOW2000下,如果想用到98或ME下命令还需要改
    别的平台下也是一样的的
    呵呵