Weird Java runtime error - currency.data

不打扰是莪最后的温柔 提交于 2019-12-10 12:35:45

问题


I keep getting this error during runtime and I have no idea what is causing it. It believes there is a file missing?

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

What is currency.data and can anyone suggest why this is happening, my JDK isn't that old since we're in 7u17 now.

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

I'm running my program with the JDK environment, I checked my jre7 folder and currency.data is present there! Why is it only present in the jre folder?


回答1:


I got a similar error and this is just to help other people who may fall into the same trap :)

Error :

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

This is because I set the global properties which turns out to be a very un-clever thing to do.

System.setProperties(new Properties());

The System properties are populated with very important data including:

  • path.separator
  • user.dir
  • file.encoding
  • file.separator
  • java.io.tmpdir

So basically don't do the above unless you know what you are doing.

If you want to a a property, do this instead:

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

or

Map myCustomMapOfProps = ...
System.getProperties().putAll(myCustomMapOfProps);



回答2:


This is my solition. You can add this in your code:

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

You must substitute the path of yours jdk version.




回答3:


I had the same problem. It was caused by a Java verison conflict ("JAVA_HOME" was set to 1.7 and the property "-Djava.home" was set to 1.6).

I was using mvn to build the project and in the environment variable MAVEN_OPTS the option "java-home" was set to the WRONG value:

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

Just CORRECT it to:

MAVEN_OPTS = -Xmx512m -XX:MaxPermSize=256m

also check your other environment variables:

MAVEN_OPTS
JAVA_HOME



回答4:


I found that currency.data is found in either:

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

or

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

For some reason, when I execute my program, Java doesn't know to look one directory deeper.




回答5:


In the old skool days, Sun specified that the JAVA_HOME should point to JDK_HOME/jre if a JDK was installed instead just the JRE.

This differentiation has slowly eroded for the same reason that 'exalator' is becoming an acceptable pronunciation for 'escalator': ubiquity.

At any rate some older apps still assume JAVA_HOME is the root of the JRE




回答6:


JDK 1.7.0_43 does not have currency.data under lib/, only within jre/lib. That forces me to change the build scripts to use JDK for compiling and then to use JRE for unit tests. Unless there is a better way.




回答7:


I had the same problem for a webapp deployed in wildfly 10 after installing a new jre while the server was running. Restarting the server resolved the problem.



来源:https://stackoverflow.com/questions/15823126/weird-java-runtime-error-currency-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!