Thursday, December 12, 2019

NetBeans: java.nio.file.AccessDeniedException thrown when copying jars to your library

After you have your coding done, you do a Clean and Build, and you see the following error message in your Output pane.

Copy libraries to C:\MyProjects\lib.
Attempt to copy C:\dynamicreports-3.2.0\lib\xalan-2.7.1.jar to C:\MyProjects\lib\xalan-2.7.1.jar using NIO Channels failed due to 'C:\MyProjects\lib\xalan-2.7.1.jar'.  Falling back to streams.
C:\MyProjects\nbproject\build-impl.xml:1212: The following error occurred while executing this line:
C:\MyProjects\nbproject\build-impl.xml:1035:
java.nio.file.AccessDeniedException: C:\MyProjects\lib\xalan-2.7.1.jar
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
at java.nio.file.Files.newOutputStream(Files.java:216)
at org.apache.tools.ant.util.FileUtils.newOutputStream(FileUtils.java:1721)
at org.apache.tools.ant.types.resources.FileResource.getOutputStream(FileResource.java:267)
at org.apache.tools.ant.types.resources.FileResource.getOutputStream(FileResource.java:241)
at org.apache.tools.ant.util.ResourceUtils.getOutputStream(ResourceUtils.java:791)
at org.apache.tools.ant.util.ResourceUtils.copyUsingStreams(ResourceUtils.java:765)
at org.apache.tools.ant.util.ResourceUtils.copyResource(ResourceUtils.java:435)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:565)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:525)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:486)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:449)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:415)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:390)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:328)
at org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs.execute(CopyLibs.java:218)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor172.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at java.util.Vector.forEach(Vector.java:1275)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor172.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor172.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:261)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:574)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:128)

To fix this problem, do one of the following.

1. Change the accessibility of your library folder.
     Right-click on the folder and select Properties. In the pop-up window, select the Security tab.               Select each group of users, click the Edit button to change their permission to access this folder.
2. Run your NetBeans as Administrator.
    Righ-click on your NetBeans icon and select Run as administrator.
3. Remove all the unused jar files from the lib directory.

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

No comments:

Post a Comment