728x90
자바에서 package를 만들면 보통 com.foo.package
와 같은 형식으로 com으로 시작하거나, org으로 시작하는 경향이 있다.
저 두개는 도메인 명의 끝에 있는 것인데, 왜 그것이 패키지명의 시작에 들어가는지 궁금해서 찾아보니 "Java Package Naming Convention"을 따르기 때문이다.
네이밍 컨벤션에 따르면 자바의 패키지명은 도메인명을 역순으로 나열하는 것이다.
예)
- 도메인명 : dobbycantype.com
- 패키지명 : com.dobbycantype
이때 com이 흔한 이유는 많은 패키지가 회사들에서 만들어지기 때문에 도메인명이 com으로 끝나고, 그래서 패키지명의 시작이 com이 되는 것이다.
org로 시작하는 것은 동일한 이유로 도메인의 끝이 org인 경우 패키지명을 그렇게 짓는다.
Java language의 패키지들은 java
, javax
로 시작한다.
참고
↓ Oracle에서 공개한 Java Package naming convention
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
↓ 위 내용을 설명해주는 스택오버플로우
https://stackoverflow.com/questions/4620045/why-is-the-root-package-in-source-code-called-com
728x90
'Java' 카테고리의 다른 글
[IDE없이Java실습#3] 클래스 파일을 소스파일과 다른 위치에 생성하기 (0) | 2022.12.25 |
---|---|
[IDE없이Java실습#2] IDE와 인터넷 없이 java 소스 두 개 컴파일 및 실행하기 (0) | 2022.12.23 |
[IDE없이Java실습#1] 터미널로 인터넷 없이 자바 파일 컴파일 및 실행 (0) | 2022.12.20 |
[Java] 자바 입문기 - 오라클 로그인 없이 JDK 설치, 이클립스 (Eclipse) IDE 설치 (0) | 2021.12.24 |