Giter Site home page Giter Site logo

javax-mode.el's Introduction

Javax Mode

Java mode extension for Emacs. Extends java-mode build source code and run tests with Maven.

Installation

git clone [email protected]:nchapon/javax-mode.el

Set up

You need to have installed Java and Maven and setup two environments variables by default in .bash_profile

  • set JAVA_HOME to target Java home directory
  • add mvn commnand in your PATH

Add this in your emacs configuration

;; Set up ENV variables to have the same as bash
(when (file-exists-p "~/.bash_profile")
  (setenv "JAVA_HOME" (shell-command-to-string "source ~/.bash_profile; echo -n $JAVA_HOME"))
  (setenv "PATH" (shell-command-to-string "source ~/.bash_profile; echo -n $PATH")))

(require 'javax-mode)

Usage

The only requirement is to have a Java Maven project.

Commands

Keybinding Description
C-c j t Jump between test and code
C-c j s Open source file
C-c j o Organize imports
C-c j x t Run JUnit tests for buffer
C-c j c Compile source code from mvn command line mvn -o compile
C-c j c Build project from mvn command line mvn -f <pom-parent> clean install

Flycheck

Flycheck can be use to check java syntax on the fly with Eclipse Compiler for Java (ECJ) ECJ is running in batch mode each time the source code is modified in a Java buffer. The Java classpath is built from maven command mvn dependency:tree

Installation

  • First you need to install emacs flycheck package (see instructions here)
  • Download ECJ

Configuration

  • Configure jx/mvn-repo-path with your maven repository :
(setq jx/mvn-repo-path "/home/nchapon/opt/m2_repo")
  • Configure jx/ecj-path to target ECJ executable tool
(setq jx/ecj-path "/home/nchapon/opt/bin/ecj-4.3.2.jar")

Before starting

  1. You should have a valid Java Maven Project.
  2. Open any Java file from this project and type jx/update-config. This will generate a file .javax-project.el used to configure java classpath and ECJ options.

Usage

In any java buffer simply enable flycheck mode, enter M-x flycheck-mode.

Known Limitations

  • At this moment could not work with Lombok

Development

Source

You will find the source code at : https://github.com/nchapon/javax-mode.el

Running tests

Tests are written with Ecukes. This library is used to write Cucumber-like tests for Emacs.

  • Install Cask
  • Run cask to install all dependencies : $ cd /path/to/javax-mode $ cask
  • Run all the tests $ cask exec ecukes --no-win

TODO

  • Flycheck : create javax project config file if does not exist before running flycheck
  • Flycheck : add hook after save maven config file to update project config
  • Flycheck : customize JVM / ECJ options
  • Inline variables in source code
  • Organize imports : customize imports order
  • Display class method names
  • Extend navigate to source code in dependencies
  • Add a real autocomplete mode
  • Can execute test not only from test case but from java source code under test buffer
  • Flycheck should work with lombok

javax-mode.el's People

Contributors

nchapon avatar

Stargazers

Michael Wall avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.