https://github.com/sublimelinter/sublimelinter-javac
SublimeLinter 3 plugin for Java, using javac -Xlint.
https://github.com/sublimelinter/sublimelinter-javac
Last synced: 4 months ago
JSON representation
SublimeLinter 3 plugin for Java, using javac -Xlint.
- Host: GitHub
- URL: https://github.com/sublimelinter/sublimelinter-javac
- Owner: SublimeLinter
- License: mit
- Created: 2013-12-29T06:34:20.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2025-04-24T10:17:56.000Z (10 months ago)
- Last Synced: 2025-04-24T11:27:58.897Z (10 months ago)
- Language: Python
- Size: 22.5 KB
- Stars: 39
- Watchers: 7
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SublimeLinter-javac
=========================
[](https://travis-ci.org/SublimeLinter/SublimeLinter-javac)
This linter plugin for [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter) provides an interface to [javac](http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html).
It will be used with files that have the "Java" syntax.
Please note that because `javac` requires a complete directory context in order to work, this linter plugin currently will only lint a file **when it has been saved**.
## Installation
SublimeLinter must be installed in order to use this plugin.
Please use [Package Control](https://packagecontrol.io) to install the linter plugin.
Before using this plugin, ensure that `javac` (JDK 1.7+) is installed on your system.
`javac` is part of the `java` developer SDK, which can be downloaded [here](http://www.oracle.com/technetwork/java/javase/downloads/index.html).
Please make sure that the path to `javac` is available to SublimeLinter.
The docs cover [troubleshooting PATH configuration](http://sublimelinter.com/en/latest/troubleshooting.html#finding-a-linter-executable).
## Settings
- SublimeLinter settings: http://sublimelinter.com/en/latest/settings.html
- Linter settings: http://sublimelinter.com/en/latest/linter_settings.html
Additional SublimeLinter-javac settings:
|Setting|Description|
|:------|:----------|
|lint|A comma-delimited list of rules to apply.|
Valid rule names are: all, cast, classfile, deprecation, dep-ann, divzero, empty, fallthrough, finally, options, overrides, path, processing, rawtypes, serial, static, try, unchecked, varargs, -cast, -classfile, -deprecation, -dep-ann, -divzero, -empty, -fallthrough, -finally, -options, -overrides, -path, -processing, -rawtypes, -serial, -static, -try, -unchecked, -varargs, none.
For example, to ignore deprecation warnings for all files in a project, you would add this to the linter settings:
```
"javac": {
"lint": "all,-deprecation"
}
```
### Passing options to `javac`
In order to configure `javac` options like the class path, source path, or file encoding,
the `args` setting can be used.
|Setting|Description|
|:------|:----------|
|`args`|An array of strings, alternating between an option and the corresponding value.|
A full list of available options is given [here][1].
For example, the following configuration defines the source file encoding,
includes the two libraries `lib/some_lib.jar` and `lib/some_other_lib.jar`
in the classpath,
and defines `src/` as the project's source path:
```
"args": [
"-encoding", "UTF8",
"-cp", "${folder}/lib/some_lib.jar:${folder}/lib/some_other_lib.jar",
"-sourcepath", "${folder}/src/"
]
```
Note that options and their values must be separate elements in the array
(i.e. `"args": ["-sourcepath", "/path/to/src"]` does work, while
`"args": ["-sourcepath /path/to/src"]` does not work).
#### Classpath
|Setting|Description|
|:------|:----------|
|`classpath`|Elements for the classpath. Accepts a list.|
To configure classpaths with a lot of elements, the `classpath` setting may
be used alternatively or in addition to `args`.
If *`-sourcepath` is unspecified* (in `args`), `-classpath` can also be used to configure source paths.
The above example would look like this:
```
"args": ["-encoding", "UTF8"],
"classpath": [
"${folder}/lib/some_lib.jar",
"${folder}/lib/some_other_lib.jar",
"${folder}/src/", // sourcepath elements go here, too
]
```
#### Project-specific options
Settings like the class path often only apply to one specific project.
The general SublimeLinter documentation also [explains][3] how to specify
project-specific settings in the `sublime-project` file.
For the example above, such a project file could look like this:
```
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"SublimeLinter.linters.javac.lint": "all",
"SublimeLinter.linters.javac.args": ["-encoding", "UTF8"],
"SublimeLinter.linters.javac.classpath": [
"${folder}/lib/some_lib.jar",
"${folder}/lib/some_other_lib.jar",
"${folder}/src/",
]
}
}
```
[1]:http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html
[2]:http://sublimelinter.com/en/latest/settings.html#settings
[3]:http://sublimelinter.com/en/latest/settings.html#project-settings