emacs java(jdee) completion 실험 노트...

primewizard의 이미지

실험 환경:
데비안 lenny
emacs 23

1) 자바관련 라이브러리 설치

# apt-get -y install sun-java6-jdk sun-java6-doc elib ant

2) 썬 자바로 설정

# update-java-alternatives -s java-6-sun

3) 일단 2.3.5.1 버전 테스트
http://sourceforge.net/projects/jdee/files/
jde-2.3.5.1.tar.gz 다운로드 받고 압축 해제 후 적당히 설치

.emacs 파일에 아래 추가

(setenv "JAVA_HOME" "/usr/lib/jvm/java-6-sun-1.6.0.12")
(setenv "CLASSPATH" ".")
 
;;cedet 로드(적당히 자신의 환경에 맞게...)
(load "~/.emacs.d/cedet")
 
(add-to-list 'load-path "/설치/경로/jde/lisp")
(require 'jde)
 
(add-hook 'jde-mode-hook
          (lambda()
	    (local-set-key [(control return)] 'jde-complete)
	    (local-set-key [(shift return)] 'jde-complete-minibuf)
	    (local-set-key [(meta return)] 'jde-complete-in-line) )  )

/설치/경로/jde/lisp/efc.el 파일 수정

(defmethod efc-coll-add ((this efc-list) item)
  "Adds an item to the list."
  (if (efc-coll-type-compatible-p this item)
      (oset this items (append (oref this items) (list item)))
    (error "Tried to add an item of type %s to a list of items of type %s"
	   (typep item) (oref this elem-type))))

함수 typep 를 함수 type-of 로...
(defmethod efc-coll-add ((this efc-list) item)
  "Adds an item to the list."
  (if (efc-coll-type-compatible-p this item)
      (oset this items (append (oref this items) (list item)))
    (error "Tried to add an item of type %s to a list of items of type %s"
	   (type-of item) (oref this elem-type))))

수정 안 하면 아래 에러 남
Debugger entered--Lisp error: (wrong-number-of-arguments #[(form val type) "
 
or 
 
apply: Wrong number of arguments: #[(form val type) "

4) jdee svn 저장소의 branches/2.4.0 테스트
구글링 결과 subversion 것을 사용하라고 해서

$ svn co <a href="https://jdee.svn.sourceforge.net/svnroot/jdee/branches/2.4.0" rel="nofollow">https://jdee.svn.sourceforge.net/svnroot/jdee/branches/2.4.0</a> jde

http://ant-contrib.sourceforge.net/
컴파일할 때 필요한 antcontrib 다운로드 받고 압축 해제 후 적당한 위치에 설치

jde/build.xml 수정

<taskdef resource="net/sf/antcontrib/antlib.xml"/>

위 부분을 아래처럼 수정
<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="/설치/경로/ant-contrib/ant-contrib-1.0b3.jar" />
  </classpath>
</taskdef>

아래 명령 실행
$ ant configure

위 명령 실행 후 생성되는 build.properties 파일 수정
cedet.dir=/설치/경로/cedet
elib.dir=/usr/share/emacs/site-lisp/elib #synaptic 으로 설치했을 경우

아래 명령 실행
$ ant build
$ ant dist

jde/dist 로 모인 파일 적당히 옮김
$ mv dist /설치/경로/jde

.emacs 파일에 아래 추가
(setenv "JAVA_HOME" "/usr/lib/jvm/java-6-sun-1.6.0.12")
(setenv "CLASSPATH" ".")
 
;;cedet 로드(적당히 자신의 환경에 맞게...)
(load "~/.emacs.d/cedet")
 
(add-to-list 'load-path "/설치/경로/jde/lisp")
(require 'jde)
 
(add-hook 'jde-mode-hook
          (lambda()
	    (local-set-key [(control return)] 'jde-complete)
	    (local-set-key [(shift return)] 'jde-complete-minibuf)
	    (local-set-key [(meta return)] 'jde-complete-in-line) )  )

JAVA_HOME 환경 변수를 설정했지만 나중에는 jde-jdk-registry 를 설정해야 할 것 같음
CLASSPATH에 "."(현재 폴더)는 jdee 를 이용해서 컴파일 및 실행하려면 필요함
JAVA_HOME(or jde-jdk-registry)와 CLASSPATH 설정 안 하면 컴파일할 때 아래 에러 남
Cannot find JDK's tools jar file (or equivalent).Type M-x describe-function [RET] jde-get-jdk-dir for more info.

M-x jde-complete

M-x jde-complete-minibuf

M-x jde-complete-in-line

주의사항:
jdee svn 저장소에서 받은 것은 ant 로 꼭! 컴파일을 하고 dist 를 만들어야함
그래야 jde.tar 파일과 jde-autoload.el 파일이 만들어져서 정상적으로 사용 가능함

--
호기심에 jdee 를 테스트해 보았지만 콘솔에서 개발할 수 밖에 없는 특수한 경우를 제외하고 자바는 eclipse 가...

그리고 svn 저장소 것은 ant 로 꼭 컴파일을 해야 jde.tar 와 jde-autoload.el 파일이 생성되고 정상적으로 사용할 수 있어서
java도 익숙하지 않고 ant 도 익숙하지 않은 관계로 엄청난 삽질(?)을 경험하고 --;
그냥 그 파일들을 포함시켜 놓으면 초보자 분들이 좀 더 편히 사용할 수 있었을 텐데 하는 아쉬움이...
(사실은 아쉬움보단 삽질을 좀 해서 억울함이... ^^;)

File attachments: 
첨부파일 크기
Image icon jde-2.3.5.1.png68.72 KB
Image icon jde-complete.png69.2 KB
Image icon jde-complete-minibuf.png71.92 KB
Image icon jde-complete-in-line.png47.05 KB
madman93의 이미지

emacs 만 고집하는 저로서는 eclipse 보다는 emacs가 좀 더 구미가 당기기는 했어도
jdee 환경을 조성하는 귀차니즘에 빠져 있었는데 많은 도움이 될 것 같습니다.
---------------------------------------------
git init
git add .
git commit -am "project init"
---------------------------------------------

---------------------------------------------
git init
git add .
git commit -am "project init"
---------------------------------------------

oppor의 이미지

프라임위자드 님의 이런 테스트 글은 거의 다 본것 같은데 여태까지의 테스트 결과를 종합해보면...

결국 "이맥스 왜 쓰나요?" 뭐.. 이렇게 생각 할 수 밖에 없네요. T.T

초보는 전용 IDE 쓰는게 답...

primewizard의 이미지

그렇게 들릴 수도 있을 것 같군요. ^^;
그러나 제 실험 노트의 목적은 각종 언어로 코딩하려고 emacs를 사용할 때
emacs 설정 때문에 사용을 포기하거나 설정 과정 중 저와 똑같은 삽질(?)을 하지 않기 바라는 마음에서 적었습니다.

개인적으로 툴의 강점,약점을 아는 것도 필요하고
그것을 바탕으로 한 툴의 선택은 취향의 문제라고 생각합니다.

--
예전의 글을 지금 읽어보니 emacs에 대한 푸념이 좀 있기는 합니다. ^^;
(기대가 그만큼 크다 보니)
오해를 줄이기 위해 기회가 되면 eclipse,vim 등등에 대한 푸념도 적어봐야겠습니다.

oppor의 이미지

프라임 위자드 님의 글이 문제가 아니라...

초보라면 당연히 저 과정을 거쳐야 하는 데다가 저렇게 삽질(?)을 하고도 만족할만한 IDE 환경이 만들어지지 않는게 문제라면 문제겠죠.

능력자들이라면 필요한걸 만들어버리겠지만 초보는 쉽지 않으니까 딱히 해결 방법도 없죠.

님의 글은 전혀 문제가 없다고 생각합니다.^^

withtw의 이미지

현재 시점의 윈도우즈XP EmacsW32에서는

1. 그냥 http://sourceforge.net/projects/jdee/files/ 에서 다운 받아서
적당한 위치에 압축을 푼 다음

2. .emacs에 위에 나온데로 경로만 수정해서 추가해주면 V2.4를 사용할수 있군요.
Cedet는 그전에 먼저 설치해 두고요.

--------------------------------------------------------------------------------
<< Cygwin 없이 Cedet 설치하기 >>

가. http://cedet.sourceforge.net/ 로 들어가서 최신 버전을 다운받는다.
나. 아무곳에나 압축을 풀고, 도스창 혹은 emacs 쉘에서 해당위치로 이동한 다음, 아래와 같이 입력한다.
(cedet-1.0pre6/cedet-build.el 파일에 나오는 내용이다.)

emacs -Q -l cedet-build.el -f cedet-build

출력메시지가 아래와 같이 나오면 성공한 것이다.
Step 1: Byte compile EIEIO...not needed
Step 2: EDE Autloads...done.
Step 3: Semantic Autloads...done.
Step 4: SRecode Autloads...done.
Step 5: Load common/cedet.el ...done
Step 6: Turning on EDE ...

마지막에 아래의 경고메시지가 나오긴 하지만 설치는 제대로 되는것 같다.
Wrong type argument: number-or-marker-p, (6912 0 . 38425)

다. .emacs 파일에 아래의 코드를 추가한다.
(load-file "설치경로/cedet-1.0pre6/common/cedet.el")
(global-ede-mode 1) ; Enable the Project management system
(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion
(global-srecode-minor-mode 1) ; Enable template insertion menu