我做了一个JAVA项目,在ECLIPSE中,我建了一个文件MANIFEST.MX,内容是:Manifest-Version: 1.0
Main-Class: com.wsy.Library
SplashScreen-Image: res/backImg.jpg
Class-Path:. lib/msbase.jar. lib/mssqlserver.jar. lib/msutil.jar
然后执行ECLIPSE导出命令,将文件打包成JAR文件,在导出的文件夹里建了LIB文件,内容是:lib/msbase.jar. lib/mssqlserver.jar. lib/msutil.jar
然后我双击该.JAR文件,却只出现登陆界面,输入用户名和密码后,却不能进入主界面,这是为什么,你能告诉我这样解决这个问题吗?我用的数据库是SQL2000,该数据库我已打上了SP4补丁。在ECLIPSE环境中能正确运行。)

解决方案 »

  1.   

    正常情况下你的jar是不会读取自身jar包以外的的文件夹特别是他所依赖的,你只有把这些lib也打进去才能执行。
      

  2.   

    直接可运行,JDK版本:1.4.2-b28package demo;import java.awt.Dimension;
    import java.io.File;import javax.swing.JDialog;
    import javax.swing.JFileChooser;public class JFileChooserDemo{
    public JFileChooserDemo(){}

    public static void main(String[] args) {
    new JFileChooserDemo().getSelectPath();
    }

    public String getSelectPath(){
    String path=null;
    JFileChooser openLicenseFile = new JFileChooser();
    openLicenseFile.setDialogTitle("文件选择");
    openLicenseFile.setApproveButtonText("选择");
    openLicenseFile.setApproveButtonToolTipText("文件选择");
    openLicenseFile.setSelectedFile(new File("*.doc"));
    openLicenseFile.setPreferredSize(new Dimension(600, 480));
    String dirName = openLicenseFile.getCurrentDirectory().toString().trim();
    if (dirName == null || dirName.trim().length() == 0) {
    openLicenseFile.setCurrentDirectory(new File("."));
    }else{
    openLicenseFile.setCurrentDirectory(new File(dirName));
    }
    int rtVal = openLicenseFile.showOpenDialog(new JDialog());
    if (rtVal == JFileChooser.APPROVE_OPTION) {
    path = openLicenseFile.getSelectedFile().getName();
    }
    return path;
    }
    }
      

  3.   

    楼主不好意思,发错了。
    有两个办法可以解决你的问题
    第一种:在你生成的jar文件同目录新建一个lib文件夹,然后把msbase.jar,mssqlserver.jar,msutil.jar拷贝到lib目录下。即可运行!
    第二种:把你生成的jar文件用解压工具打开,把msbase.jar,mssqlserver.jar,msutil.jar中的类文件全部拖放到你生成的jar中,这样也可以运行!
      

  4.   

    可能是包里面的资源读不到,比如
    this.setIconImage("/image/bsc.jpg");//往往都是读不到jar里面的图片的
    应该为
    this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/image/bsc.jpg")));