为什么我的类路径最后只能与冒号一起使用? [英] Why does my classpath only work with a colon on the end?

查看:79
本文介绍了为什么我的类路径最后只能与冒号一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅当我在类路径的末尾加上:时,我的应用程序才开始记录到log4j.我已经在类路径中有属性文件和jar了,所以我不确定发生了什么.用冒号结束类路径怎么办?启动命令将变成这样:

My app only starts logging to log4j if I put a : on the end off the classpath. I already have the properties file and the jar in the classpath, so I'm not sure what's going on. What does ending the classpath with a colon even do? The startup command thus becomes something like this:

java -cp path-to-log4j.properties:bunch:of:other:stuff: app

如果我删除了最后一个冒号,它将停止日志记录,好像找不到log4j.我的问题是,最后一个冒号实际上在做什么,因为它将添加到类路径的哪个目录中?

If I take that last colon off it stops logging, as if it can't find log4j. My question is, what is that last colon actually doing, as in what directory is it adding to the classpath?

推荐答案

通常,您应该将类​​路径放在引号-cp"path:path2"中.

usually you should put the classpath in quotes -cp "path:path2".

冒号可能会添加当前目录.

The colon might add the current directory.

无法将文件(jar文件除外)直接添加到类路径.仅目录.今天就读^^

One cannot add files (except jar files) directly to the classpath. Only directories. Read that today^^

这篇关于为什么我的类路径最后只能与冒号一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆