D:\java\SourceCode\nt目录下有Cat.java和Dog.java两个源代码分别如下:
package gjx;
public class Cat{
public static void main(String[] args){
System.out.println("努力就会有收获");
}
}
public class Dog{
public static void main(String[] args){
gjx.Cat c = new gjx.Cat();
}
}
在D:\java\SourceCode\nt目录下运行javac -d . Cat.java,在D:\java\SourceCode\nt目录下生成了gjx文件夹并包括了Cat.class文件。
当在D:\java\SourceCode\nt目录下运行javac Dog.java时,出现如下错误:
D:\java\SourceCode\nt>javac Dog.java
Dog.java:4: 错误: 程序包gjx不存在
gjx.Cat c = new gjx.Cat();
^
Dog.java:4: 错误: 程序包gjx不存在
gjx.Cat c = new gjx.Cat();
^
2 个错误



Your Answer
4 answers
Hot tools Tags
Hot Questions
T-SQL split string based on delimiter
2026-01-05 13:22:09
Z-index with before pseudo-element
2026-01-05 13:01:05
How to generate UML diagrams (especially sequence diagrams) from Java code?
2026-01-05 12:43:11
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
Douyin level price list 1-75
20417
7
20417
7
wifi shows no ip assigned
13577
4
13577
4
Hot Article
How to set up price alerts so you don't miss key entry points?
2026-01-01
By DDD
Why do professional traders advise newbies to start with low leverage?
2026-01-01
By DDD
How to Fix a 'KERNEL_DATA_INPAGE_ERROR' on Windows?
2026-01-02
By 下次还敢
How to reverse a string in Python? (code examples)
2025-12-31
By 下次还敢






