Java Files.copy AccessDeniedException复制到C:\Windows\System32\ICE\u JNIRegistry.dll时发生异常

Java Files.copy AccessDeniedException复制到C:\Windows\System32\ICE\u JNIRegistry.dll时发生异常,java,java-7,java.nio.file,Java,Java 7,Java.nio.file,我正在使用Java7API提供的新的“Files.copy[InputStream source,Path dest,REPLACE_EXISTING]”方法 我正在将.dll从InputStream复制到C:\Windows\System32。显然,我需要管理员权限才能完成此操作。我正在以管理员权限从命令提示符运行.jar文件,因此这应该不是问题 当我尝试这样做时,我得到一个java.nio.file.AccessDeniedException。以下是整个堆栈跟踪的打印输出: java.nio

我正在使用Java7API提供的新的“Files.copy[InputStream source,Path dest,REPLACE_EXISTING]”方法

我正在将.dll从InputStream复制到C:\Windows\System32。显然,我需要管理员权限才能完成此操作。我正在以管理员权限从命令提示符运行.jar文件,因此这应该不是问题

当我尝试这样做时,我得到一个java.nio.file.AccessDeniedException。以下是整个堆栈跟踪的打印输出:

java.nio.file.AccessDeniedException: C:\Windows\System32\ICE_JNIRegistry.dll
        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.j
ava:83)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.jav
a:97)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.jav
a:102)
        at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystem
Provider.java:229)
        at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvid
er.java:430)
        at java.nio.file.Files.newOutputStream(Files.java:170)
        at java.nio.file.Files.copy(Files.java:2832)
        at prerequirementform.PreRequirementForm.<init>(PreRequirementForm.java:
49)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.izforge.izpack.installer.InstallerFrame.loadPanels(Unknown Source
)
        at com.izforge.izpack.installer.InstallerFrame.<init>(Unknown Source)
        at com.izforge.izpack.installer.GUIInstaller.loadGUI(Unknown Source)
        at com.izforge.izpack.installer.GUIInstaller.access$100(Unknown Source)
        at com.izforge.izpack.installer.GUIInstaller$2.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:688)
        at java.awt.EventQueue$3.run(EventQueue.java:686)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
java.nio.file.AccessDeniedException:C:\Windows\System32\ICE\u JNIRegistry.dll
位于sun.nio.fs.WindowsException.translateToIOException(WindowsException.j
艾娃:83)
位于sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.jav
a:97)
位于sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.jav
a:102)
位于sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystem
Provider.java:229)
位于java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvid
er.java:430)
位于java.nio.file.Files.newOutputStream(Files.java:170)
位于java.nio.file.Files.copy(Files.java:2832)
在prerequirementform.prerequirementform。(prerequirementform.java:
49)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
在sun.reflect.delegatingConstructor或AccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:525)
位于com.izforge.izpack.installer.InstallerFrame.loadPanels(未知源
)
位于com.izforge.izpack.installer.InstallerFrame。(未知来源)
位于com.izforge.izpack.installer.GUIInstaller.loadGUI(未知源)
位于com.izforge.izpack.installer.GUIInstaller.access$100(未知来源)
位于com.izforge.izpack.installer.GUIInstaller$2.run(未知源)
在java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)中
位于java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
在java.awt.EventQueue.access$200(EventQueue.java:103)
在java.awt.EventQueue$3.run(EventQueue.java:688)
在java.awt.EventQueue$3.run(EventQueue.java:686)
位于java.security.AccessController.doPrivileged(本机方法)
在java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
位于java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
位于java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
在java.awt.EventDispatchThread.PumpeEventsforFilter(EventDispatchThread。
爪哇:161)
在java.awt.EventDispatchThread.PumpeEventsforHierarchy(EventDispatchThre
ad.java:150)
位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
在java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

任何帮助都将不胜感激。

不。这是我使用IzPack创建的安装程序包的一部分。这只是一个资源,但它没有被积极使用。你能从一个以管理员权限启动的cmd.exe进行相同的复制吗?我刚刚测试了你的建议。我可以毫无问题地复制。