javac

Dependency problems with my ANT script

I'm having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. Oddly enough, I can buil...

Problem with dependencies using Ant from the shell.

I'm having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. (As a pathelement, along...

Strange/simple batch question regarding Java/Ant

For my company, I'm making a batch script to go through and compile the latest revisions of code for our current project. I'm using Ant to build the class files, but encountered a strange error. One of the source files imports .* from a directory, where there are no files (only folders), and in fact, the folders needed are imported right...

Passing "-J-Duser.language" into javac through ant to ensure compilation errors are reported in the correct language

My PC is currently set up as Japanese for testing purposes. If my java project has a compilation error the message is reported in Japanese. e.g. Compiling 1 source file to [...directory...] [...class...].java:172: シンボルを見つけられません。 I would prefer to see the errors in english. Without using ant the fix for this is to use javac -J-Du...

Preserving parameter/argument names in compiled java classes

When I compile something like this: public class MyClass { void myMethod(String name, String options, String query, String comment) { ... } } and compile this to a class file, it seems that argument names are lost. That is, when some other Java code references MyClass and wants to call or overwrite myMethod, my IDE (c...

Multiple .class files generated for a class?

Out of curiosity, why are sometimes multiple Java .class files generated for a class after compilation? For example, my application has six classes. For one class, a total of 10 .class files has been generated, starting from MyClass#1 up to MyClass#10. ...

Javac: Treat warnings as errors

I have an Ant file that compiles my program. I want the javac task to fail if any warning was reported by the compiler. Any clue on how to do that? ...

How can I post process the files compiled by javac ant task?

I need the list of files that were compiled during this run. I want to feed this list to a subsequent post-processing step. I have found an option to list (see listfiles option) the files compiled during this run, but it seems only good for displaying the list on console. Any idea? Edit: I am talking about incremental compiles, so t...

Discover the class of a methodinvocation in the Annotation Processor for java

I am writing some tools for our build system to enforce some strict calling conventions on methods belonging to classes containing certain annotations. I'm using the Compiler Tree API... What i'm wondering is when traversing the 'tree', how can you tell the type of class/interface for a MethodInvocation. I'm subclassing TreePathScan...

what are the $1 in class file?

C:\Program Files\Java\jdk1.6.0_05\CoreJava\v1\v1ch2\WelcomeApplet>dir Volume in drive C has no label. Volume Serial Number is 2041-64E7 Directory of C:\Program Files\Java\jdk1.6.0_05\CoreJava\v1\v1ch2\WelcomeApplet 2009-07-02 23:54 . 2009-07-02 23:54 .. 2004-09-06 14:57 582 WelcomeApplet.ht...

How to include default package in Ant javac Task

When I: <javac srcdir="${src}" destdir="${build.classes.dir}" classpathref="classpath"> <include name="ObjectInDefaultPackage"/> <include name="com/mypackage/**"/> </javac> It will no longer add compile and add the class ObjectInDefaultPackage that's in the default package (ie. it's not packaged, it's sitting on the man ${src}...

Invoking javac.exe within Vim

Hi everyone. I had previously asked a question about using Vim to develop Java, but I ended up realizing JDK works very well and that Ant is wayyy too much complicated for a starter like me. Things got a little bit clearer, and now I have a question again. When I work with a file such as 'filename.java', I need to be able to use 'javac...

how to hava javac compiler write the output to both file and console?

I am running javac task using ant and I send the output to a log file using -Xstdout compiler argument for reporting purposes, but I would like the output also still being send to the console so hudson can capture it for on screen review. Is there a way for this to be done? ...

ClassPath in Ant for Javac task

I have following ant file to build. But unfortunately <project default="build.deploy.start" basedir="."> <property name="target.dir" value="C:\tom\webapp\"/> <property name="basesrc.dir" value="c:\SimpleChat\"/> <property name="classes.target" value="${basesrc.dir}\WebContent\WEB-INF\classes"/> <property name="src.dir"...

Maven2 compiler custom execution source directory and target directory

I want to run the maven compiler plugin in a different phase and with different sourceDirectories and destinationDirectories such that code from directories other than src/main/java and src/test/java can be used. I thought the solution would look something like the below, where the phase I was linking it to was pre-integration-test. How...

How do I set -Dfile.encoding within ant's build.xml?

I've got java source files with iso-8859-1 encoding. When I run ant, I get "warning: unmappable character for encoding UTF-8". I can avoid this if I run ant -Dfile.encoding=iso-8859-1 or add encoding="ISO-8859-1" to each javac statement. Is there a way to set the property globally within build.xml? <property name="file.encoding" valu...

AdaptRecursive StackOverflowError

While compiling my project I get: The system is out of resources. Consult the following stack trace for details. java.lang.StackOverflowError at com.sun.tools.javac.code.Type$WildcardType.isSuperBound(Type.java:435) at com.sun.tools.javac.code.Types$1.visitWildcardType(Types.java:102) at com.sun.tools.javac.code.Types$1.visi...

Are there any Java-compilers that leverage an OSGi-environment instead of using the classpath?

Are there any ways to make javac use an existing OSGi-environment for the resolution of build-time dependencies instead of setting the classpath explicitely? I know I could write an OSGi-component that uses the Compiler-API of the JDK, but I think there should be a more straightforward solution. Alternatively, if no such extension is av...

Find type parameter of method return type in Java 6 annotation processor

I'm writing a tool that uses the annotation processor to generate source code depending on the return type of methods of an annotated class. The return type is always some subtype (interface or class) of an interface A that defines a type variable T. interface A<T>{T m();}; I would like to find the type parameter for the method m() r...

How do I make the JDK the default JRE?

I use Eclipse with ant scripts, and Eclipse works well with the default JRE installation on Windows XP. The annoyance comes when I want to run ant scripts compiling with the javac-tag, where it fails because there is no tools.jar in the classpath. I've gotten the idea that if I could make the JDK become the default Java on Windows, the...