【发布时间】:2012-09-26 22:29:23
【问题描述】:
好吧,所以在实现org.apache.commons.lang3.text.WordUtils 类之后,我希望能够使用WordUtils.wrap(String str, int width) 函数。但我遇到了减速带。
我能够毫无问题地编译这个程序(我应该提到的是一个小程序)。我只需要设置一个 CLASSPATH 环境变量来引用 apache jar 文件,然后通过 appletviewer 让程序运行。但是,当我到达使用 WordUtils.wrap() 函数的代码部分时,一切都变糟了,我在命令提示符下收到大约 20 行运行时错误。
错误:
Caught a SecurityException reading the system property 'awt.toolkit'; the System
Utils property value will default to null.
Caught a SecurityException reading the system property 'file.encoding'; the Syst
emUtils property value will default to null.
Caught a SecurityException reading the system property 'java.awt.fonts'; the Sys
temUtils property value will default to null.
Caught a SecurityException reading the system property 'java.awt.graphicsenv'; t
he SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.awt.headless'; the
SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.awt.printerjob'; th
e SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.class.path'; the Sy
stemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.compiler'; the Syst
emUtils property value will default to null.
Caught a SecurityException reading the system property 'java.endorsed.dirs'; the
SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.ext.dirs'; the Syst
emUtils property value will default to null.
Caught a SecurityException reading the system property 'java.home'; the SystemUt
ils property value will default to null.
Caught a SecurityException reading the system property 'java.io.tmpdir'; the Sys
temUtils property value will default to null.
Caught a SecurityException reading the system property 'java.library.path'; the
SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.runtime.name'; the
SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.runtime.version'; t
he SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.util.prefs.Preferen
cesFactory'; the SystemUtils property value will default to null.
Caught a SecurityException reading the system property 'java.vm.info'; the Syste
mUtils property value will default to null.
Caught a SecurityException reading the system property 'user.country'; the Syste
mUtils property value will default to null.
Caught a SecurityException reading the system property 'user.region'; the System
Utils property value will default to null.
Caught a SecurityException reading the system property 'user.dir'; the SystemUti
ls property value will default to null.
Caught a SecurityException reading the system property 'user.home'; the SystemUt
ils property value will default to null.
Caught a SecurityException reading the system property 'user.language'; the Syst
emUtils property value will default to null.
Caught a SecurityException reading the system property 'user.name'; the SystemUt
ils property value will default to null.
Caught a SecurityException reading the system property 'user.timezone'; the Syst
emUtils property value will default to null.
这是导致所有这些麻烦的代码行:
String strWrap = WordUtils.wrap("A really really really really really long sentence.", 50);
这里发生了什么?
【问题讨论】:
-
向我们展示更多代码如何?您的代码是否直接使用 SystemUtils? SystemUtils 正在尝试读取由于浏览器中的安全限制而可能不允许小程序读取的系统属性。
-
没有在我的代码(这是一个 200 行的文件)中使用 SystemUtils,只使用 WordUtils...?
标签: java apache runtime-error word-wrap securityexception