개요
- 자바 패키지 컴파일 및 실행
animal/Dog.java
PHP
Copy
package animal;
public class Dog {
public void bark() {
System.out.println("Woof!");
}
}
mypackage/MyClass.java
PHP
Copy
package mypackage;
import animal.*;
public class MyClass {
public static void main(String args[]) {
Dog mydog = new Dog();
mydog.bark();
}
}
Console
Copy
testuser@localhost:~/project1$ find
.
./mypackage
./mypackage/MyClass.java
./animal
./animal/Dog.java
Console
Copy
testuser@localhost:~/project1$ javac -d . mypackage/MyClass.java
testuser@localhost:~/project1$ java mypackage.MyClass
Woof!
testuser@localhost:~/project1$ java mypackage/MyClass
Woof!
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.