James Gosling:Java 是 10 年前发明的语言,在 Sun ,没有多少人用开发集成环境(IDE),因为 IDE 是面向低级程序员的,而真正的程序员使用的最好的工具应该是 Emacs,这个 23 年前,我就为之付出了一些心血的家伙。
一、原料:
0、厨房:Windows XP,另外‘厨房重地,谢绝闲人(hacker、Trojan horse= =)’;
1、emacs一只,产地:http://ftp.gnu.org/gnu/windows/emacs/latest/或者从CVS摘一只(不过我的CVS源码没有编译成功:P);
2、JDE及其文档各一斤(这个是原材料里面最大的东东了),出自http://java.sun.com/j2se/downloads/;
3、类浏览器speedbar、语法分析器semantic和eieio(OO lisp)各一汤匙,k级别的小东西,可以单独下载最新版本,唉?麻烦?!没关系,http://cedet.sourceforge.net/这里面有个cedet的包,有了它就都有了;
4、elib(Emacs lisp Utilities)一个,从http://jdee.sunsite.dk/elib-1.0.tar.gz挖一个;
吼~,到这里就万事具备了,生火~~,喂~~~呜~~~
二、流程:
1、将emacs洗净解压,在其根目录新建一个HOME目录,当然此目录建在其它地方也可以,在厨房内(也就是系统内啦)设置一个名为HOME的环境变量,变量的值是刚才新建的HOME目录的路径;
2、将jde、文档、cedet、elib这一些材料全都洗净解压,把他们解压到Home目录中便于使用;
3、接下来的操作在jde的文档里已经有详细的英文说明,所以下面挑出必要的几个设置来说一说,在HOME的目录里面建一个名称为'.emacs'的文件(用记事本编辑即可),此处http://jdee.sunsite.dk/install.html有一个 minimal .emacs file(内容我放在‘附’里面),可直接把它copy&paste到.emacs中,此外最多只需要改动四句:
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
‘~’号代表流程1中所设置的系统环境变量值(即Home目录的绝对路径),它的后面分别是jde、cedet、elib相对此目录的相对路径,至此,启动emacs能看到.emacs的载入过程,如果能正常启动,则说明配置文件可以无误的载入,下面安装完jdk就可以看到Jdee大餐了,下面设置过程如果输入命令是出错可以按快捷键Ctrl-g中断命令;
4、按M-X(Alt-x),然后输入M-x customize-variable ,回车后,会有Customize variable:的提示,然后输入jde-jdk-registry,会看到
点‘INS’,
输入JDK的版本号和绝对路径,如:
点‘INS’,
输入JDK的版本号和绝对路径,如:
点‘INS’,
输入JDK的版本号和绝对路径,如:
点击Save for Future Sessions表示将来编辑的工程都会使用此设置,这一步会自动写入你的.emacs文件中,最后Finish就可以了。
5、选择JDK:输入M-x customize-variable 回车,然后输入jde-jdk 回车,
选择后,Save for Future Sessions 最后Finish就好了。此时JDK就算设置好了,你试着输入M-x jde-mode就可以进入到emacs的java编辑世界了,菜单上也多了许多,效果如下
6、JDEE的功能还远远不止与此,想不想要Eclipse或Jbuilder的代码提示功能,简单设置一下马上就可以用。输入M-x customize-variable 回车,然后输入jde-complete-function 回车,如下:
选择你喜欢的方式,并点State保存选择,效果如下:
选择你喜欢的方式,并点State保存选择,效果如下:
7、还有像Jbuiler或Eclipse一样的树型的工程浏览器SpeedBar,如下图
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
6、JDEE的功能还远远不止与此,想不想要Eclipse或Jbuilder的代码提示功能,简单设置一下马上就可以用。输入M-x customize-variable 回车,然后输入jde-complete-function 回车,如下:
选择你喜欢的方式,并点State保存选择,效果如下:
选择你喜欢的方式,并点State保存选择,效果如下:
7、还有像Jbuiler或Eclipse一样的树型的工程浏览器SpeedBar,如下图
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
选择后,Save for Future Sessions 最后Finish就好了。此时JDK就算设置好了,你试着输入M-x jde-mode就可以进入到emacs的java编辑世界了,菜单上也多了许多,效果如下
6、JDEE的功能还远远不止与此,想不想要Eclipse或Jbuilder的代码提示功能,简单设置一下马上就可以用。输入M-x customize-variable 回车,然后输入jde-complete-function 回车,如下:
选择你喜欢的方式,并点State保存选择,效果如下:
选择你喜欢的方式,并点State保存选择,效果如下:
7、还有像Jbuiler或Eclipse一样的树型的工程浏览器SpeedBar,如下图
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
6、JDEE的功能还远远不止与此,想不想要Eclipse或Jbuilder的代码提示功能,简单设置一下马上就可以用。输入M-x customize-variable 回车,然后输入jde-complete-function 回车,如下:
选择你喜欢的方式,并点State保存选择,效果如下:
选择你喜欢的方式,并点State保存选择,效果如下:
7、还有像Jbuiler或Eclipse一样的树型的工程浏览器SpeedBar,如下图
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.
这就像一个IDE了吧,还能安装插件成为XDE,关于这个可以参考JDEE的文档或http://jdee.sunsite.dk/jdedoc/html/jde-ug/jde-ug.html,这里就不再详细说明了。
三.附:minimal .emacs file
;; This .emacs file illustrates the minimul setup
;; required to run the JDE.
;; Set the debug option to enable a backtrace when a
;; problem occurs.
(setq debug-on-error t)
;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))
;; Initialize CEDET.
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
;; Include the following only if you want to run
;; bash as your shell.
;; Setup Emacs to run bash as its primary shell.
(setq shell-file-name "bash")
(setq shell-command-switch "-c")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-sh-args '("-login" "-i"))
(if (boundp 'w32-quote-process-args)
(setq w32-quote-process-args ?\")) ;; Include only for MS Windows.