兄弟们看看新生吧,凑字数凑字数

写入HlloWorld时出错:HlloWorld.class拒绝访问

img

img


你想要在一个只读的文件夹中编译生成class文件,是不可以的呀!
除非你用管理员运行cmd 才可以!!!

很高兴得到你的采纳!!!

没写public吧
public class HelloWorld{...这样的

你的文件名应该和你定义的类名一致

img


这种格式

程序没问题,不写public也能正常编译。
提示拒绝访问的话是可能你这个文件夹没有写的权限,
把HelloWorld.java换个地方编译试一下,比如c:/temp目录,或者桌面。

把这个代码运行编译试试,应该是你写的不规范,编译通过了,但是运行有问题


public class est {
    public static void main(String[] args) {

        int width = 20;           // width of cube in cms
        double length = 30.5;     // length of cube in cms
        double depth = 10.5;      // depth of cube in cms

        // compute the volume
        double volume = width*length*depth;

        // write the result
        System.out.print("Your box has a volume of ");
        System.out.print(volume);
        System.out.println(" cubic centimetres.");
    }
}

是没有配置jdk吗