자바에서 파이썬파일(.py) 불러오기, 자바에서 파이썬 사용하기
프로젝트를 생성하기에 앞서 자이썬(Jython)을 다운받아줍니다. 자이썬(Jython)이란 자바 플랫폼용 파이썬, 즉 자바 언어로 만들어진 파이썬(Python)이라고 생각하시면 되겠습니다. 다운로드 주소 : h
thisisspear.tistory.com
1 . 자이썬 설치
주소 : http://www.jython.org/downloads.html
2. 이클립스 bildpath에 추가하기
3. 자바 파일 내부에서 import org.python.util.PythonInterpreter; 선언
4. 내부 선언
ex) private static PythonInterpreter interpreter;
4. 객체 생성(실체화, 인스턴스화)
ex) interpreter = new 객체_이름();
5. 사용 코드
ex) interpreter.exec("파이썬 코드");
예제
import org.python.util.PythonInterpreter;
public class main {
private static PythonInterpreter interpreter;
public static void main(String[] args) {
interpreter = new PythonInterpreter();
interpreter.exec("from java.lang import System");
}
}
'청년취업아카데미 > Java' 카테고리의 다른 글
CardLayout 사용 간단 예제 (0) | 2021.02.10 |
---|---|
자바에서 웹 데이터 읽어오기 (0) | 2021.02.08 |
[21.01.15 Java] Card Layout (0) | 2021.01.15 |
[21.01.14 Java] GUI (0) | 2021.01.14 |
[21.01.12 Java]GUI Programming방법 (0) | 2021.01.12 |