14

我在运行时不断收到此错误,我不知道是什么原因造成的。它认为缺少文件?

Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.7.0_07\lib\currency.data

什么是currency.data并且任何人都可以提出为什么会发生这种情况,我的 JDK 并没有那么旧,因为我们现在在 7u17 中。

Exception in thread "AWT-EventQueue-0" java.lang.InternalError
    at java.util.Currency$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.Currency.<clinit>(Unknown Source)
    at java.text.DecimalFormatSymbols.initialize(Unknown Source)
    at java.text.DecimalFormatSymbols.<init>(Unknown Source)
    at java.text.DecimalFormatSymbols.getInstance(Unknown Source)
    at java.text.NumberFormat.getInstance(Unknown Source)
    at java.text.NumberFormat.getNumberInstance(Unknown Source)
    at java.util.Scanner.useLocale(Unknown Source)
    at java.util.Scanner.<init>(Unknown Source)
    at java.util.Scanner.<init>(Unknown Source)
    at ciphor.CiCompile$7.actionPerformed(CiCompile.java:458)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.7.0_07\lib\currency.data (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    ... 48 more

我正在使用 JDK 环境运行我的程序,我检查了我的 jre7 文件夹并且currency.data存在于那里!为什么它只存在于 jre 文件夹中?

4

7 回答 7

14

我遇到了类似的错误,这只是为了帮助可能落入同一陷阱的其他人:)

错误 :

java.lang.InternalError: java.io.FileNotFoundException: null/lib/currency.data (No such file or directory)

这是因为我设置了全局属性,结果证明这是一件非常不明智的事情。

System.setProperties(new Properties());

系统属性填充了非常重要的数据,包括:

  • 路径分隔符
  • 用户目录
  • 文件编码
  • 文件分隔符
  • java.io.tmpdir

所以基本上不要做上面的事情,除非你知道你在做什么。

如果您想要一个属性,请改为执行以下操作:

System.getProperties().put("SOME_KEY", "SOME_VALUE");

或者

Map myCustomMapOfProps = ...
System.getProperties().putAll(myCustomMapOfProps);
于 2015-11-16T06:14:11.697 回答
5

这是我的解决方案。您可以在代码中添加它:

System.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.8.0_60\\jre");

您必须替换您的 jdk 版本的路径。

于 2016-10-21T08:57:32.553 回答
3

我有同样的问题。它是由 Java 版本冲突引起的(“JAVA_HOME”设置为 1.7,属性“-Djava.home”设置为 1.6)。

我正在使用 mvn 来构建项目,并且在环境变量 MAVEN_OPTS 中,选项“java-home”被设置为WRONG值:

MAVEN_OPTS = -Xmx512m -XX:MaxPermSize=256m "-Djava.home=C:\Program Files\Java\jdk1.6.0_35\jre"

只需将其更正为:

MAVEN_OPTS = -Xmx512m -XX:MaxPermSize=256m

还要检查您的其他环境变量:

MAVEN_OPTS
JAVA_HOME
于 2014-06-04T16:19:24.837 回答
1

我发现currency.data在以下任何一个中都可以找到:

C:\Program Files\Java\jdk1.7.0_17\jre\lib

或者

C:\Program Files\Java\jdk1.7.0_07\lib

出于某种原因,当我执行我的程序时,Java 不知道更深入地查看一个目录。

于 2013-04-04T23:11:49.353 回答
0

在过去,Sun 规定如果安装了 JDK 而不是只安装了 JRE,则 JAVA_HOME 应该指向 JDK_HOME/jre。

由于“exalator”正在成为“escalator”的可接受发音,这种差异已经慢慢消失:无处不在。

无论如何,一些较旧的应用程序仍然认为 JAVA_HOME 是 JRE 的根

于 2013-11-20T23:41:31.457 回答
0

JDK 1.7.0_43 lib/下没有currency.data,只有jre/lib下。这迫使我更改构建脚本以使用 JDK 进行编译,然后使用 JRE 进行单元测试。除非有更好的方法。

于 2013-12-13T14:50:24.110 回答
0

在服务器运行时安装新的 jre 后,我在 Wildfly 10 中部署的 webapp 遇到了同样的问题。重新启动服务器解决了这个问题。

于 2017-10-20T09:47:26.070 回答