Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javac error message does not display entire filepath

When using javac (or the ant task ), the error message does not include the entire filepath, it only includes the file name. For example,

$ javac src/path/to/Filename.java
Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
              ^

What I would like is,

$ javac src/path/to/Filename.java
src/path/to/Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
              ^

My problem is that vim quickfix does not work if it's not given the entire filepath, not just the filename. With just the filename, a new empty file is opened up after running :make.

I'm using:

  • Debian wheezy
  • openjdk-6-jdk v6b23~pre7-1
  • javac v1.6.0_23
like image 572
Felipe Avatar asked Aug 21 '11 04:08

Felipe


1 Answers

I don't think there is a simple way to do this.

However, I believe that there is a complicated way. It basically involves writing your own compiler runner that makes use of a JDK installation's ability to load and run the Java compiler inside of a running program. You need to implement a lot of stuff, but the key thing is a diagnostic processor that formats the compiler error messages in the way that you need them to be formatted.

Here are some relevant links:

  • Package javax.tools - provides interfaces for tools which can be invoked from a program, for example, compilers.
  • JavaCompiler - the interface implemented by the compiler
  • FileObject - the interface that the compiler uses to represent source files; e.g. in diagnostics. Note the toUri() method!
like image 81
Stephen C Avatar answered Nov 14 '22 22:11

Stephen C