Published: 25 Jan 2018 › Updated: 25 Jan 2018
자바 프로그래밍 (어플리케이션에서 class파일 떨구기)
최근에 하던일중에 필요해서 사용하게된 API입니다.
바로 .java파일을 읽어서 .class 파일로 만들어주는 API입니다.
사용법은 단순하게
JavaCompiler 를 이용해서 .run() 메소드를 실행시키면되는데요
실제 소스로 보여드리면
이런식으로 사용하시면 됩니다.
결과화면을 보시면
넵 컴파일이 완료되었습니다.!!
실제 폴더에 가보시면 Test.java와 같은 폴더에 .class파일이 생성되게 됩니다.
참고로 해당 API를 사용하실때 이클립스의 옵션으로 jre를 사용하시게되면
nullPointException 에러가 뜨게됩니다 그때는
이클립스의 Window -> Preferences -> Java -> Intalled JREs 에서
jre가 아니라 jdk로 설정을 바꾸어 주시면 됩니다.
Leave 자바 프로그래밍 (어플리케이션에서 class파일 떨구기) to:
Read more #kr posts
Best Posts From 디쿠
We have not curated any of gmba's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.