help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java programming and emacs


From: Steve Revilak
Subject: Re: Java programming and emacs
Date: Fri, 8 Jan 2010 19:54:12 -0500
User-agent: Mutt/1.5.19 (2009-01-05)

I am looking for a good setup that could integrate java
programming, checkstyle plugin support and SVN (code I am working
on is hosted on code.google.com).

  I do a fair amount of java programming with emacs, so I can share a
  few things that have been helpful for me.

    - If you're using ant to build your java code
      (setq compile-command "ant -find build.xml ")
      is helpful

Yeah, I am stuck with ant and friends (maven2 is another tool I
am using). What do I need to load in order to use compile ?
(sorry I am really new to this).

You shouldn't need any special load or require statements to use
compile.  Start by typing M-x compile RET.  After doing so, the
minibuffer will be populated with the the value of `compile-command'.
The default compile-command is "make -k".  Putting

  (setq compile-command "ant -find build.xml ")

into ~/.emacs changes the value of compile-command, so that M-x
compile offers "ant -find build.xml ", instead of "make -k".

Once "ant -find build.xml" appears in the minibuffer, you can do one
of two things: press RETURN; or, provide additional command-line
arguments to ant (e.g., a build.xml target) and press RETURN.

Once you press RETURN, emacs runs ant, and the output goes to the
*Compilation* buffer.


- If you're using ant, set the environment variable
  "ANT_ARGS=-emacs".  This causes ant to emit output in a
  format that compliation mode can understand

Ok.

If you've set ANT_ARGS=-emacs, then compile will be able to parse the
file/line location of each error.  Use C-x ` to iterate over the
errors.  Then compile again :)

I also have

  (define-key ctl-x-map "\^M" 'compile)

so that I can start a compilation with C-x RETURN.  But that's just a
personal preference.


- If checkstyle has an ant task, then you can probably just run
  checkstyle with ant (i.e., put a checkstyle target in your build.xml).

What does this mean ? I have to add an ant task in my build
system ? Can't I just invoke checkstyle through emacs on a buffer

Whenever I use syntax-checkers, etc. on a project, I've always set up
build.xml targets for them.  Having a build.xml target usually makes
the process very easy to automate.  Once I've written the ant task for
automation, then those ant tasks become the natural way to run the
syntax checkers interactively.  (They're just different compile
targets.)  This is just my personal preference.

It's been a very long time since I've used checkstyle, but there is an
ant task available [1], if you want to try that approach.

There may be a way to "just run checkstyle on a buffer", but I don't
have an easy recipie for doing so.


What about JDEE ? Did you ever test it ? Sounds like something
for a serious java coder (which I am not ;)).

Sorry, I've never tried JDEE.

Steve

[1] http://checkstyle.sourceforge.net/anttask.html

Attachment: pgpEA9ATpHDSI.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]