is it possible to disable javac’s inlining of static final variables?

Item 93 of Java Puzzlers (Joshua Bloch) says that you can work round this by preventing the final value from being considered a constant. For example: public class A { public static final int INT_VALUE = Integer.valueOf(1000).intValue(); public static final String STRING_VALUE = “foo”.toString(); } Of course none of this is relevant if you don’t … Read more

Java Access Denied

Your working directory is C:\Program Files (x86)\Java\jdk1.6.0_17\bin. You are not allowed to write files here. Copy your java files to a different directory and try to compile them there. edit: You should include C:\Program Files (x86)\Java\jdk1.6.0_17\bin to your PATH environment variable. And set JAVA_PATH to C:\Program Files (x86)\Java\jdk1.6.0_17. set JAVA_PATH=”C:\Program Files (x86)\Java\jdk1.6.0_17″ set PATH=%PATH%;”C:\Program Files … Read more

Javac “cannot find symbol”

First, To compile the java source file using javac you need to specify the files to compile explicitly. Example: javac PathToSourceFile/FileName.java you need not provide the path if the source file is in the current working directory. Second, whenever java encounters import abc.xyz.ClassName; it tries to resolve abc/xyz/ClassName with respect to the classpath or current … Read more

Suppress javac warning “…is internal proprietary API and may be removed in a future release”

This particular warning cannot be suppressed. At least not officially. The warning about proprietary API means that you should not use the API which causes the warning. Sun does not support such API and the warning will not be suppressible. If you’re particularly determined, you can use the highly undocumented javac -XDignore.symbol.file flag which will … Read more

Make javac treat warnings as errors

Use the -Werror flag. It’s not listed in the -help output, but it works. I found it through this blog entry and tested on my own code (in NetBeans with Ant). The output was: MyClass.java:38: warning: [serial] serializable class MyClass has no definition of serialVersionUID public class MyClass extends JComponent { 1 warning BUILD FAILED … Read more

Compiling java files in all subfolders? [duplicate]

On Windows… Create a batch file: for /r %%a in (.) do (javac %%a\*.java) …then execute it in the top-level source folder. On Linux… javac $(find ./rootdir/* | grep .java) Both answers taken from this thread… http://forums.oracle.com/forums/thread.jspa?threadID=1518437&tstart=15 But as others suggested, a build tool would probably prove helpful.