你可以在前面加个反斜杠/
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
     可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]

解决方案 »

  1.   

    谢谢,我试过加反斜杠,但是效果一样,未打包可以运行,打包包括config.properties也可运行,但是打包不包括配置文件就不行了,config.properties就放在jar旁。
    到底是什么原因呢?
      

  2.   

    你把config.properties放在Jar包外,那你怎么发布你的程序呢?
    如果你不放在Jar包里,就需要设置ClassPath.
      

  3.   

    properties都需要放在classpath中才能被调到,
    比如你的jar路径是 ..\WEB-INF\lib
    那么你的properties文件需放在..\WEB-INF\classes中。
      

  4.   

    因为是配置文件,所以必须放在jar包外面,发布的时候再做一个安装程序吧。
    我怎么为jar包设ClassPath?行命令下应该是 -classpath 我是用Jbuilder7的向导来做的不知道在那里设了,现在在家里,没有环境试,明天上班试成之后立刻发分,谢谢各位先。
      

  5.   


    用这个肯定能行!private void init() {
            FileInputStream is=null;
            try{
                if(System.getProperty("file.separator").equals("/"))
                    is= new FileInputStream("./mo_config/db.properties");
                else
                    is= new FileInputStream(".\\mo_config\\db.properties");
            }catch(FileNotFoundException e){
            System.out.println("File db.properties not found");
            }
            Properties dbProps = new Properties();
            try {
                dbProps.load(is);
            }
            catch (Exception e) {
                System.err.println("Can't read the properties file. " +
                "Make sure db.properties is in the CLASSPATH");
                return;
            }
            logFile = dbProps.getProperty("logFile", "DBConnectionManager.log");
        }
      

  6.   

    改成FileInputStream后它访问不到任何属性了,即getProperty为空,该文件肯定被load到了,不知道为什么?