2

I'm trying to get sublimelinter to work with java so that I can lint my java program, but I don't know what javac -Xlint or what the path is. So my question is, what is PATHs and -xlint?

I've got sublimelinter pointed to C:\Program Files\Java\jdk1.7.0_17\bin for java files, but it's still not working.

2

Sublimelinter doesn't have easy to follow documentation. So here's what I did to get it working for me.

In your sublimetext project file, you have to set up the SublimeLinter object and configure the Java lint settings.

Suppose you have a project structure like so:

C:\path\to\projectname
├───src
│   ├───main
│   │   ├───java
│   │   │   └───com
│   │   │       └───yoursite
│   │   ├───resources
│   │   └───webapp
│   │       └───WEB-INF
│   └───test
│       └───java
│           └───com
│               └───yoursite
└───target
    ├───classes
    │   └───com
    │       └───yoursite
    ├───projectname
    │   ├───META-INF
    │   └───WEB-INF
    │       ├───classes
    │       │   └───com
    │       │       └───yoursite
    │       └───lib
    ├───javadoc-bundle-options
    ├───maven-archiver
    └───surefire
  • working_directory : The absolute path to your work area. (Anyone know how to reference paths in the folders.path?) Also, the rest of the paths are relative to this one.
  • lint_args : arguments passed to javac
    • -sourcepath : path to your source files.
    • classpath : path to compiled classes.
    • -Xlint, -Xlint:-serial: javac command line options.
    • {filename} : SublimeLinter reference to the current file.

From javac

-Xlint: Enable all recommended warnings. In this release, all available warnings are recommended. -Xlint:serial: Warn about missing serialVersionUID definitions on serializable classes.

projectname.sublime-project 1

{
    "folders": [
        {
            "path": "C:\\path\\to\\projectname",
            "name": "projectname"
        }
    ],
    "settings": {
        "SublimeLinter":
        {
            "Java":
            {
                "working_directory": "C:\\path\\to\\projectname",
                "lint_args":
                [
                    "-sourcepath", "src/main/java;c:\\some\\absolute\\path",
                    "-classpath", "C:\\Users\\UERNAME\\.m2\\repository\\path\\to\\file.jar;target/classes",
                    "-Xlint", "-Xlint:-serial",
                    "{filename}"
                ]
            }
        }
    }
}
  • Agreed. Way too much in my opinion. – grocky Mar 7 '14 at 17:46
0

You can also simply add to your CLASSPATH the folders containing the classes you are using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.