java命令 包,从命令行运行java包

I have read the previously posted questions. Some are vague and none solved my problem so I am forced to ask again.

I have two simple classes,

package One;

import One.Inner.MyFrame;

public class test

{

public static void main(String args[])

{

MyFrame f= new MyFrame();

}

}

And the other class is,

package One.Inner;

import java.awt.*;

import javax.swing.*;

public class MyFrame extends JFrame

{

public MyFrame()

{

setPreferredSize(new Dimension(400,560));

setVisible(true);

}

}

I am at base folder "basic" in windows cmd. I compile using

basic> javac *.java -d .

A folder and subfolder is created.

cd One

basic\One> java test

This generates a big set of errors. Many answers directed to specify the full path which didnt work.

My classes are in One so specifing One using -cp didnt work either.

I am very confused. Please help.

解决方案

You'd run it as:

java One.Test

... but from the root directory (basic), not from the One directory. You always specify the fully-qualified class name.

Oh, and package names in Java should be lower-case, so it should be one and one.inner, not One and One.Inner. Just a convention, but one which pretty much everyone follows.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值