|
|
This tutorial will walk you through the steps to set up and start working with JavaNLP using JetBrains' IntelliJ IDEA. The first part gives the simplest set of instructions, for when you have Java 6 on your machine, and you exploit the checked in Eclipse project structure. The second set of instructions cover installing SoyLatte (to get JDK1.6, if you don't have an Intel Mac) and setting up everything by hand for checking out all of the 2008 JavaNLP reorganization as a multi-module project, including using Java 6 with it on the Mac. The third part is older material, some of which is now dated. (The useful older material should be integrated at some point.)
IntelliJ is fast. After using the bloated beast that is Eclipse, using IntelliJ makes my neural receptors hum with delight. Loading up and switching between projects is faster. Setting preferences is faster. Tweaking the classpath, refactoring, searching for references, and generating code coverage reports: all faster. -- macjavadev
These instructions set up the whole of the reorganized JavaNLP, using Java 6 to compile under IntelliJ IDEA 7.0.3 or higher under Mac OS X 10.5 or higher with Apple Java 6 installed. They exploit the Eclipse project structure checked into JavaNLP.
/Applications/IntelliJ IDEA
7.0.3.app/Contents/Info.plist and change the line:
<string>-Xms16m -Xmx256m -XX:MaxPermSize=120m -Xbootclasspath/p:../lib/boot.jar -ea</string>
to perhaps
<string>-Xms32m -Xmx320m -XX:MaxPermSize=150m -Xbootclasspath/p:../lib/boot.jar -ea</string>
File | Close
Project. You should see the Quick Start page with buttons on the
left and Plugins on the rightCheck out from Version Control | Subversion. If
you haven't done this before, press the + sign and add the path
svn+ssh://jacob.stanford.edu/u/nlp/svnroot .trunk, click the triangle again, and you should
see javanlp and scalanlp.
Click on javanlp, and then press Checkout./Users/manning/javanlp. You need to create it first so it
is an existing directory to select. There's a little icon for that in
the dialog. Click Okay. Have it check out HEAD recursively.
Choose a subversion format. If still running Mac OS X 10.5, note that
choosing 1.5 will mean that the local repository will be
incompatible with the command-line version of svn (but I did it anyway).
If you're running
Mac OS X 10.6, you have svn v1.6, and life is good.
Go and get coffee and wait a while.Yes when asked if you would like to create an
IntelliJ IDEA project for the sources you checked out. Say that you
want to import the project structure from an external model. Click Next.
Choose Eclipse. Click Next. Select the projects directory
(javanlp/projects), and click to Link created IntelliJ IDEA
mdoules to Eclipse project files. Put test in the Detect
test sources box. Click Next.
JavaNLP). Click Finish.
Drink your coffee.These instructions set me up with the whole of the reorganized JavaNLP, using Java 6 to compile under IntelliJ IDEA 7.0.3 under Mac OS X 10.5. I've now put in JavaNLP IntelliJ module specification files (*.iml) files. I think they may be used when you do the checkout, and so a few of these things you might no longer have to do (let me know if you try this).
~/Software, but
anywhere should work. /Applications/IntelliJ IDEA
7.0.3.app/Contents/Info.plist and change the line:
<string>-Xms16m -Xmx256m -XX:MaxPermSize=120m -Xbootclasspath/p:../lib/boot.jar -ea</string>
to perhaps
<string>-Xms32m -Xmx320m -XX:MaxPermSize=150m -Xbootclasspath/p:../lib/boot.jar -ea</string>
File | Close
Project.Check out from Version Control | Subversion. If
you haven't done this before, press the + sign and add the path
svn+ssh://jacob.stanford.edu/u/nlp/svnroot .trunk, and
then again to see javanlp. Click on javanlp,
and then press Checkout./Users/manning/javanlp. Have it check out recursively.
Sit back and wait a while.Yes when asked if you would like to create an
IntelliJ IDEA project for the sources you checked out.IntelliJ IDEA | Preferences.... Click on
Project Settings. Under Project JDK, click New. Choose JSDK. Navigate
to the one you installed and select it (the root directory). Choose
OK. It will show up as 1.6 (1.6.0_03-p3) in the combobox. Choose 5.0 as
the project language level. For Project compiler output, I changed
out to classes, but whatever.
mt/lib (fastutil-5.0.9.jar
and bsh.jar). The first of these screws up compilation,
because Core should use the more recent
fastutil-5.0.10.jar. (This is something IntelliJ seems to
do badly: it gives all libraries to all modules by default, rather than
just the libraries that correspond to a module in the source tree
organization.)
jre/lib subdirectory of your soylatte
installation and multiselect all 6 jar files there and say OK.
Build | Make Project. Wait again. But it
should work without errors (only warnings). Yippee!!.
C:\Documents and
Settings\user\IdeaProjects\project_nameC:\Program Files\Java\jdk1.5.0C:\Documents and
Settings\user\IdeaProjects\project_namesrc\ for sources files, etc. The default is to use the same dir as the project file,
which again is probably fine.)Name: and
the path to your JDK. The rest of the defaults are fine.
Now you've got an empty project. The next step is to download javaNLP.
File->Settings and open the Version
Control dialog. In the pull-down menu at the top, select "CVS". Check out the options below if you like, but the defaults
should work fine. Click "OK".File->Check Out from CVS and hit Configure.
Set the CVS root to
:ssh:username@nlp.stanford.edu:/u/nlp/cvsrootC:\Documents and
Settings\user\IdeaProjects\project_name. JAVANLP_HOME refers to the
module_content_root or the base directory of your local copy of the repository.
/u/nlp/java/lib directory (or download and unpack the
/u/nlp/java/javanlp-lib.tar.gz file) to the newly created
JAVANLP_HOME/lib directory.
File->Settings->Paths dialog, and select the "Libraries (Classpath)"
tab. Click "Add Jar/Directory", and navigate to (and expand) JAVANLP_HOME/lib. (Hint: use the little
blue "IJ" icon to open JAVANLP_HOME.) Highlite all of the individual
.jar files that you just downloaded and hit "OK".Settings->Global
Code Style or you can import the
"official" javaNLP settings file. Just download this file (it's a
.jar file because IntelliJ is written in java, but don't let
that confuse you; just import it as directed here), and then select
File->Import Settings and point the browser to the file.
Ant Build under the Window menuAnt Build window, click on the "+"Ant Build
window to compile the targetBuild menu, all of the compilation
targets should be available under the JavaNLP submenuUsing the Eclipse classpath integration in IntelliJ, after a .classpath change through svn, it seems like IntelliJ can get confused and lose your project sources. The easiest way to fix it seems to be to find the .classpath file, do svn revert, and the project will load all over again, and it will be right this time.
In order to make sure your file encoding is UNIX-friendly (so you don't
get all those ^M's at the end of each line from Window's carriage
returns), under Settings->IDE Settings->General, set the
"Default Encoding" to UTF-8.
If someone checked in some bad code that's breaking your compile, or you just want to speed up the
compile time for the stuff you're working on, you can exclude files and
directories from the IntelliJ compiler in the
File->Settings->Compiler dialog.
When you create new files automatically with IntelliJ, it will make a
JavaDoc file header for you. Unfortunately, this header won't even be
proper JavaDoc format. Please go to Settings->File Templates
and change it. (Hint: add an @author tag!) If you import our style settings file, this will be done for
you.
One IntelliJ default that I (personally) find annoying, is that if you
click way off the end of the line, it allows the caret to go there,
filling in the intervening space with space characters. You can turn this
off in Settings->Editor->Virtual Space by unchecking the
"Allow placement of caret after end of line" option.
CTRL-b on any class or variable name to go to its
definition), and refactoring (e.g. type CTRL-ALT-n to inline
a variable or function, or SHIFT-F6 to rename a variable or
class). You can change the key mapping to emulate emacs or Mac OSX. You
can use and define your own quite sophisticated code-sensitive macros (try
declaring a Collection and then type "itco" *TAB*).
Time spent exploring and get used to using IntelliJ's advanced capabilities will be repaid ten-fold in terms
of saved time coding in the future. (Not to mention reduced headaches!)
|
Local links: NLP lunch · PAIL lunch · NLP Reading Group · JavaNLP (javadocs) · ScalaNLP · machines · Wiki |
Site design by Bill MacCartney |