javac

Specifying the Eclipse compiler completely from _within_ build.xml

As an experiment we want to build our products using the Eclipse java compiler (ecj-3.5.jar downloaded from eclipse.org) on the runtime version of Java 6 instead of the JDK, and as I understand it, it is a matter of adding this jar to the ant classpath, and setting the build.compiler property to point to the adapter. By including <pro...

passing precompile directives to javac ?

I am writing a desktop and j2me application. I have debug statements in program. Currently to avoid those getting compiled i use as following. We are doing this to reduce size of jar. (Specifically for mobile) ConstantFile.java Boolean ConstantFile.DebugEnabled = false; if(ConstantFile.DebugEnabled) { log.debug("msg"); } But this is ...

Why does javac checkcast arrays twice?

Examining bytecode, I've noticed javac seems to duplicate checkcast instructions when casting to array types. Cast.java: class Cast { void test(Object a) { Object[] b = (Object[])b; } } javap disassembly of the javac compiled version void test(java.lang.Object); Code: 0: aload_1 1: checkcast #2; //class "[Ljava/...

javac - differences between classpath and sourcepath options

Hi, I read the Sun documentation and a lot of Q/A on SO but I'm still a little bit confuse regarding the differences between the javac options -cp and -sourcepath. Let say I have this directory structure: c:\Java\project1\src (where the .java source files are) c:\Java\project1\bin (where the .class will be or are already) The clas...

OS X: Terminal output of javac is garbled.

I've got my computer set up in Japanese (hey, it's good language practice), and everything is all fine and dandy... except javac. It displays localized error messages out to the console, but they're in Shift-JIS, not UTF8: $ javac this-file-doesnt-exist.java javac: ?t?@?C??????????܂???: this-file-doesnt-exist.java ?g????: javac <option...

Include an interface from the same package (Java)

Hi, I'm new to Java (C++ guy myself) and am trying to compile a simple program (testing different random number algorithms) in Java. I have an interface that I want to use to implement another class with, both of these items are in the same package. So I have two files right now in my "Random" package directory--"RandomInterface.java"...

Package does not exist

I get an "Build failed" error with error output when I try to build my project in Eclipse: [javac] ......\src\example\servlet\ScrapingServlet.java:10: package org.apache.http.client does not exist [javac] import org.apache.http.client.HttpClient; But the Eclipse editor does not give any error. I added the jars to the project with P...

Tricky compiler behavior

Simple java code snippet. It has three classes. After compiling the code please delete A.class and then execute the code. Code still runs, why its not checking whether the byte code of A exists or not? class A { static { System.out.println("In the class A"); } public A() { } } class B { private A a = null; ...

Force an unchecked call

Hello, Sometimes, when using Java reflection or some special storing operation into Object, you end up with unchecked warnings. I got used to it and when I can't do anything about it, I document why one call is unchecked and why it should be considered as safe. But, for the first time, I've got an error about a unchecked call. This fun...

Use javac fork attribute with IBM JDK

Hi - I have a large ant build that I'm working on, that is currently running out of memory. One ways I've read that can help mitigate this problem is to use javac fork="true" to run javac in a separate jvm. My problem is that I need to compile the project with the IBM JDK (this is not the JDK referenced by JAVA_HOME, and I would pref...

How to compile runnable jar from packages?

Hey. My java application has got a package structure similar to this; src/com/name/app , src/com/name/app/do , src/com/name/utils/db and so on. How would I go about compiling java files in these directories in to a runnable jar? I need to package required libraries into the generated JAR (jdbc). I've always done these things in Eclip...

Compile classfile issue in Spring 3

I have used spring framework 3 for my application. Everything is ok while developed in Netbeans But i need a custom build and done for the same The build created without any issue, but i got the following error The error occurred while calling the following method @RequestMapping(value = "/security/login", method = RequestMethod....

compiling java program

If the java program is compiled as javac t1.java > a //error contents redirecedt to a,file a.But a doesnt have the error contents The contents of t1.java is as: class t1{ public static void main(String[] args) { System.out.printn("Hello World!"); // Display the string. } } So now there is a error i.e, println is writte...

How to get more details of a java compilation

Hi, We are using an ant script in order to build our application. I recently made a change in one jar required by our app. However, when running the ant script, the compilation fails and the error message shown let me think that the compiler is using a previous version of the jar. Also, compilation throug my IDE works fine. Manual comp...

Is javac enough to build an OSGi bundle?

To produce a bundle from source using a tool such as javac, you need to provide it with a linear classpath. Unfortunately, it won't work in some situations still perfectly legal from an OSGi point of view: dependencies with embedded JAR in them; same packages contained by different dependencies. Since javac doesn't understand OSGi me...

Yet another Java classpath problem

Hi I've been working on a project in Netbeans. Now I'd like to submit it and allow the markers to compile it with a script. However, I get the NoClassDefFoundError when I try to run via the command line. Even when setting the classpath to the current directory manually. javac Main.java works fine then calling java -classpath . Main g...

why java 1.4 compiler does not complain about a third party library compiled with 1.5 compiler ?

Why java 1.4 compiler does not complain about a third party library compiled with 1.5 compiler ? The problem is encountered at runtime UnsupportedClassVersionError . ...

Ant fails without message at javac

I've written an Ant build.xml file which obtains a number of source files via WSDL and compiles them. These have been working on an old, now destroyed (and therefore unavailable for comparison), system but the build process isn't completing on this newer, faster system. The relevant section of the build file looks like this (updated): ...

Hudson jobs won't call javac?

Hi, I have just set up Hudson on my server. For some reason, my build will not call javac to compile my builds...? I have set the path to the JDK in the Manage Hudson area, and it seems to recognise it (doesn't give me a warning). Is there something else I'm supposed to do? Here's a sample console output of one of my jobs (note how java...

do not use com.sun.xml.internal.*?

Hi all, Is this statement true: com.sun.xml.internal package is an internal package as the name suggestes. Users should not write code that depends on internal JDK implementation classes. Such classes are internal implementation details of the JDK and subject to change without notice One of my colleagues used one of the classe...