Java 访问被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1939656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:38:09  来源:igfitidea点击:

Java Access Denied

javawindows-7javac

提问by Newb

C:\Program Files (x86)\Java\jdk1.6.0_17\bin>javac VendingMachine.java
VendingMachine.java:27: error while writing VendingMachine: VendingMachine.class
 (Access is denied)
public class VendingMachine
       ^
1 error

Here is the code from my editior from line 27 to 39:

这是我的编辑器第 27 至 39 行的代码:

public class VendingMachine /*This is line 27*/
{
   private int itemPrice;

   private int currentBalance;

   private int totalCollected;

   public VendingMachine(int itemCost)
   {
       itemPrice = itemCost;

   } /*line 39*/

I am thinking my problem might be related to Win7 Prof: (Access is denied)

我想我的问题可能与 Win7 Prof 相关:(访问被拒绝)

How do I resolve this or what do I need to be doing or reading to get this to work?

我该如何解决这个问题,或者我需要做什么或阅读什么才能让它发挥作用?

Thank you for not flaming.

谢谢你没有发火。

I just changed the folder options such that I am the given full (Access...), now I just have to figure out why I am not getting any output, when running javac VendingMachine.java I guess a new question is in order.

我刚刚更改了文件夹选项,以便我获得完整的(访问权限...),现在我只需要弄清楚为什么我没有得到任何输出,在运行 javac VendingMachine.java 时,我想有一个新问题。

采纳答案by tangens

Your working directory is C:\Program Files (x86)\Java\jdk1.6.0_17\bin. You are not allowed to write files here. Copy your java files to a different directory and try to compile them there.

你的工作目录是C:\Program Files (x86)\Java\jdk1.6.0_17\bin. 这里不允许写文件。将您的 java 文件复制到不同的目录并尝试在那里编译它们。

edit:

编辑:

You should include C:\Program Files (x86)\Java\jdk1.6.0_17\binto your PATHenvironment variable. And set JAVA_PATHto C:\Program Files (x86)\Java\jdk1.6.0_17.

您应该包含C:\Program Files (x86)\Java\jdk1.6.0_17\bin到您的PATH环境变量中。并设置JAVA_PATHC:\Program Files (x86)\Java\jdk1.6.0_17

set JAVA_PATH="C:\Program Files (x86)\Java\jdk1.6.0_17"
set PATH=%PATH%;"C:\Program Files (x86)\Java\jdk1.6.0_17\bin"

After that, you can call javacfrom where ever you like.

之后,你可以javac从任何你喜欢的地方打电话。

回答by Jerome

You don't have write access in C:\Program Files (x86). Put your sources elsewhere.

您在 C:\Program Files (x86) 中没有写访问权限。把你的资源放在别处。

回答by Jcoder

I had same error, just Run Cmd prompt as Administration mode.Hope it will solve your Problem!

我有同样的错误,只是运行 Cmd 提示作为管理模式。希望它能解决你的问题!