UCB CS61b——Class 1

编译

在terminal中,运行Java程序,首先dir(相当于Linux中的ls)和cd到对应文件夹
javac xxx.java编译Java程序

C:\Users\phoeb\IdeaProjects\beginner\src\hello_pkg>javac hello_world.java

用window中的type命令查看编译出的class文件(不同于Linux中的cat)

C:\Users\phoeb\IdeaProjects\beginner\src\hello_pkg>type hello_world.class
漱壕   8 
         
     <init> ()V Code LineNumberTable main ([Ljava/lang/String;)V
SourceFile hello_world.java     Hello world Phoebe

然后运行报错

C:\Users\phoeb\IdeaProjects\beginner\src\hello_pkg>java hello_world
错误: 找不到或无法加载主类 hello_world
原因: java.lang.NoClassDefFoundError: hello_pkg/hello_world (wrong name: hello_world)

再来看看hello_world.java的内容

C:\Users\phoeb\IdeaProjects\beginner\src\hello_pkg>type hello_world.java
package hello_pkg;

public class hello_world {
    public static void main(String[] args){
        Syste
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值