I'm experimenting with java annotation processors. I'm able to write integration tests using the "JavaCompiler" (in fact I'm using "hickory" at the moment). I can run the compile process and analyse the output. The Problem: a single test runs for about half a second even without any code in my annotation processor. This is way too long t...
I keep my java files in non-standard places, e.g. class p1.p2.cl
resides in file src/p2/cl.java, not src/p1/p2/cl.java.
How to code javac ant task so that unmodified files would not recompile each time?
thanks,
Alexei
...
I've come across an oddity of the JLS, or a JavaC bug (not sure which). Please read the following and provide an explanation, citing JLS passage or Sun Bug ID, as appropriate.
Suppose I have a contrived project with code in three "modules" -
API - defines the framework API - think Servlet API
Impl - defines the API implementation - t...
Given the default classpath:
/foo
And this directory structure:
foo
|
test
|
xcom
|--A.class
|--B.java
And these two files:
package xcom;
public class A { }
package xcom;
public class B extends A { }
Which allows B.java to compile? (Choose all that apply.)
A. Set the current directory to xcom then invoke
jav...
C:\Program Files (x86)\Java\jdk1.6.0_17\bin>javac VendingMachine.java
VendingMachine.java:27: error while writing VendingMachine: VendingMachine.class
(Access is denied)
public class VendingMachine
^
1 error
Here is the code from my editior from line 27 to 39:
public class VendingMachine /*This is line 27*/
{
private int it...
I have a program that allows a user to type java code into a rich text box and then compile it using the java compiler. Whenever I try to compile the code that I have written I get an error that says that I have an illegal character at the beginning of my code that is not there. This is the error the compiler is giving me:
C:\Users\Trav...
Calling this method:
public static @Nonnull <TV, TG extends TV> Maybe<TV> something(final @Nonnull TG value) {
return new Maybe<TV>(value);
}
like this:
public @Nonnull Maybe<Foo> visit() {
return Maybe.something(new BarExtendsFoo());
}
compiles just fine in Eclipse, but javac gives an "incompatable types" warning:
found ...
Hi.
Trying to create a test app that imports another test package.
The test apps are listed, as is the compile cmd and the err..
The files are all in the same dir. I was able to compile the MyIncorrectnessListener.java, and the MycssErrorHandler.java with no warnings/errs.
I'm trying to figure out what's the cause of the err >>> sjsu...
I am trying to write an annotation processor in the JSR 269 format which uses javac's Compiler Tree API to do some source code analysis. I am interested in member select expressions, such as method calls.
I can easily get the name of the method (or field, etc.) being selected. But I want to know what type the member is being selected fr...
I try to figure out how organize source and class files working with packages. I found a very useful tutorial. But I still have some questions.
As far as I understood it is a good practice to have an isomorphism between name of packages and name of the directories where elements of a package are stored. For example if I have a package n...
Is there any way to force Maven 2 (>2.0.10) to print the actual javac commands it's executing. We keep running out of memory even though we've bumped up the max using MAVEN_OPTS. I'd like to be able to see the actual command being executed that is running out of memory.
I've tried using the verbose setting below in the pom file's plugin...
Hi all,
I want to pass any enum value to method in utility class and get another enum value of same enum type. Something like this:
public class XMLUtils {
public static Enum<?> getEnumAttribute(Element element, String name,
Enum<?> defaultValue) {
if (element.hasAttribute(name)) {
String valueNam...
I've looked at a bunch of different examples, and tried several variations, but can't seem to get this working correctly. It also appears that you can't exclude an entire directory with javac, but only files, which I suppose means you can't specify a package? Here is what I have:
<javac srcdir="src" destdir="WEB-INF/classes" excludes="p...
To tell the truth, I am quite confused on all these terms (JDK/JRE/Java SDK). I am not sure what each one does.
When I first started doing simple java examples in eclipse, I am pretty sure I only had the JRE, which I believed was the default java installer regular users use to be able to run java programs/applets on their system.
Howev...
I have a ant javac task which is supposed to run some annotation processor. It works fine when run from a batch file, but fails with
Error running javac.exe compiler
when started from eclipse. Normal compiling javac tasks work just fine.
I guess ant started from eclipse uses some different compiler?
How do I change it to the normal c...
I'm running a multi-threaded build with two dependant com.sun.tools.javac.Main.compile() invocations running on separate threads with ~10ms pause between them. Every now (every 100 builds or so), the second javac complains about bad class formats in the outputs from the first javac.
This is on linux, but it has to work on all os'es. Wh...
I'm using ant 1.8.0 and java 1.6.0.17 and I'm running into a strange problem.
In my build.xml, I have a simple task that compiles the code
<javac destdir="${dir.build.classes}" debug="on">
<classpath refid="classpath"/>
<src path="${dir.src.java}"/>
</javac>
In the "classpath" is a jar, call it library.jar
In a later task, I...
My source files are in this folder: c:\data\mycompany.
All of my source files contain the following as the first line: package mycompany; Now from the c:\data folder, I compiled everything using this command: javac mycompany/*.java -extdirs c:\some\other\folder\with\libs. This compiles fine. Now when I try to execute it (again from c:\d...
I have a jar called "MyTools". The jar is in c:\data folder. I created a new file in the same folder called "UseTools.java". Now I would like to use some of the classes from the MyTools.jar in my UseTools.java. I tried this but it doesnt seem to work:
import MyTools.*;
public class UseTools
{
public static void main(String[] args)...
How to compile all files in directory to *.class files?
...