This version is rather old but works well for pretty printing
The new version is all-singing-all-dancing including not only an improved pretty printer, but also refactoring, metrics, cut&paste detection, bug finding, coding standards support and an AST viewer. JavaStyle has been tested on jEdit 4.2pre5 with J2SDK1.4.2_01 and jEdit4.2pre8 with J2SDK1.5.0beta1, both on Windows XP.
Download JavaStyle from plugin central by using the Plugin Manager.
Development versions may be obtained from http://sourceforge.net/projects/jrefactory/. They should be unzipped into the jEdit jars directory (in either the jEdit settings directory or the jEdit application directory). Current versions of JavaStyle use the following library jars:
care should be taken to ensure that only one version of these jars is present. A future version of JavaStyle will package all these jars in a single jar and compress them to take up less space.
After downloading JavaStyle appears as a plugin which may be obtained from the Plugins menu.
JavaStyle has many options for pretty printing and others for controlling the coding standards checking. These may be accessed either from the menu Plugins->JavaStyle->Options... or from Plugin->Plugin Options... the second option only allows acces to the default options, whereas the first option allows the options for particular projects to be set seperately. The JavaStyle plugin finds out what projects are available from the ProjectViewer plugin, if its not loaded then you just get the default options.
The option system is quite complex, it will allow almost any style of pretty printing you could desire, don't be afraid to experiment, copy a complex Java source file to a temporary location and see the results on that. You will almost certainly need to change the Author in the JavaDoc Tags tab (its currently set to me!).
Perhaps the two most important options are on the General tab Reformat when buffer is saved when ticked causes JavaStyle to reformat the buffer whenever it is saved (i.e just before it is saved) and this could change how your code looks considerably (sorting the methods for example). The other Perform coding standards check when buffer is saved is very useful on fast machines as it notifies you of problems immediately, it is however quite slow and so most appropriate for fast machines (2GHz Pentium 4 equivalent or faster)
Each Project may have its own values of any of the options, they are stored as changes to the default options. Tick the left hand box on a project option pane and then select the desired state of the option for that project.
If you need to look at the pretty.settings options file look in <user.home>/.jedit/javastyle/.JRefactory for the default settings, settings for the projects are contained in subdirectories from here.
Note: the current version of JavaStyle is not very efficient at creating the Options dialog box. It may take several seconds to load if there are lots of projects.
There are three ways of building JavaStyle for jEdit.
Its Easiest, to download the JavaStyle-jedit-2.8.x-source.zip and unzip directly into the jEdit jar directory. You should have a directory structure something like this:
Open the build.xml with AntFarm and execute the jEdit.JavaStyle.jar target. The resulting jar file is copied into the ant.build/lib/ directory, use the Plugin Manager to unload the JavaStyle plugin (uncheck it in the manage tab) copy the JavaStyle.jar from ant.build/lib/ to jEdit4.2/jars/ and reload it using the Plugin Manager.
Alternatively download the whole JRefactory-2.8.x-full.zip distribution, unzip it into a clean directory and again execute the jEdit.JavaStyle.jar target. You will need to copy the jedit.jar, ErrorList.jar and ProjectViewer.jar from the jEdit application into the JRefactory/jar/ directory first.
Alternatively use anonymous CVS to download the current version of JReafactory and build it. It is found on sourceforge.
The open source JEdit is an editor first and an IDE second. There are a large number of plugins available for it covering most aspects of development. Version 4.2 has much faster start-up performance and lazy loading of plugins. JavaStyle fully supports jEdit 4.2 features.
Pretty Printer/Beautifier is a tool that allows you to clean up the indenting and formatting of your java source code.
This tool has a powerful feature of being able to insert the appropriate javadoc comments so that the javadoc program does not generate error messages for missing fields. To simplify writing javadoc comments, some methods have javadoc comments automatically generated based on the name of the method.
JRefactory is a tool that allows you to perform the following refactorings:
It updates the java source files as appropriate.
Printing provides the ability to print UML diagrams.
BugFinding uses the findbugs tool to find many common sources of bugs in code.
UML Diagrams come as part of the Refactoring support, they can be resized are useful for navigating round lots of code.
Cut & Paste detection looks for similar sections of source code throughout a set of files.
AST Viewer shows the result of the Java parser as an Abstract Syntax Tree. XPath queries may be performed on the tree.
Metrics gathers metrics about your java source code.
Stub Generator creates a file that allows the refactory tool to display Java JDK library classes (or other applications where you have access to the source code, but you don't intend to change the source code). This facility is used for the refactoring tool to show classes from 3rd party vendors in the refactoring GUI. (This has been tested on JDK 1.4.2_01, but should work with other Java 2 JDKs)
This section is intended for plugin developers and those who create beanshell scripts.
load the Java source code into a buffer then call:
org.acm.seguin.ide.jedit.JavaStyleActions.beautify(view, buffer, false);where view is the current view and buffer is the buffer you loaded the Java source into. After the call the buffer may be modified, it is not modified if the reformatting makes no changes.
The entire pretty printing reformat is covered in one undoable edit.
org.acm.seguin.ide.jedit.JavaStyleActions.openUML(view,browser);
Last Modified: 28 April 2004