Study/개발 Tip

[Developer Setting] Sublime Text3 Java Setting | 서브라임텍스트3 자바 환경설정하기

AC 2021. 4. 20. 00:06

 

개발을 하면서 IDE 툴을 찾다가 서브라임텍스트3이 제일 가볍고 간편하게 만질 수 있다.

확장성도 좋고... 툴도 가벼워서 VSCode와 같이 쓰면 딱이다.

이번은 서브라임텍스트에서 자바설정을 한번 해보고자 한다. 

생각보다 많이 어려워서 많이 해맸던 것 같다.

 

예비 준비

JDK 설치, 내 Java 환경 변수 구성에 대한이 기사를 참조 할 수 있습니다. 여기서 자세한 내용은 다루지 않겠습니다.

Sublime Text 3 설치

Sublime Text 3 구성

1. 새 텍스트 문서를 만들고 이름을 JavaC.sublime-build (접미사 참고)로 지정하고 Sublime으로 열고 다음 내용을 채우고 저장합니다.

{
    "cmd": ["javac", "$file_name", "&&", "java", "$file_base_name"], 
    "working_dir": "${project_path:${folder}}", 
    "selector": "source.java", 
    "shell": true, 
    "encoding":"utf-8"  
}

2. Sublime 설치 경로에서 Java.sublime-package를 찾습니다. Sublime Text 3 \ Packages

압축 소프트웨어로 열려면 마우스 오른쪽 버튼을 클릭하고 (압축 해제가 아님, 여기서는 WinRAR을 사용합니다) 원본 파일을 JavaC.sublime-build로 바꿉니다. 

3. Sublime—> Preference—> Browse Packages, 열린 창에서 User 폴더를 두 번 클릭하고 새 파일 JavaC.sublime-build를 만들고 Sublime으로 열고 아래 코드를 붙여넣고 저장하고 닫습니다.

{
    "cmd": ["javac", "-encoding", "UTF-8", "-d", ".", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.java",
    "encoding": "utf-8",
    //End after executing the above command
    // The following commands need to be run by pressing Ctrl+Shift+b
    "variants": [{
        "name": "Run",
        "shell": true,
        "cmd": ["start", "cmd", "/c", "java ${file_base_name} &echo. & pause"],
        // /c is to close the cmd window after executing the command,
        // /k does not close the cmd window after executing the command.
        // echo. is equivalent to typing a carriage return
        // The pause command makes the cmd window close after pressing any key
        "working_dir": "${file_path}",
        "encoding": "utf-8"
    }]
}

 

4. 테스트
Java 프로그램을 작성한 다음 Ctrl + Shift B or Ctrl + B를 직접 컴파일하고 실행합니다.

 

 

왜 콘솔창에 안들어가는지는 의문... 아마 서브라임텍스트의 경로문제인듯

LIST