Is there a performance difference between Javac debug on and off?

In any language, debugging information is meta information. It by its nature increases the size of the object files, thus increasing load time. During execution outside a debugger, this information is actually completely ignored. As outlined (although not clearly) in the JVM spec the debug information is stored outside the bytecode stream. This means that … Read more

How to set a java compiler in Netbeans

Right click on your project –> Project Properties Then in Sources set Source/Binary Format to JDK 7. EDIT 1 : There is a NetBeans issue: Works fine in J2SE project, Web project specific problem. The problem is that fork=”false” the JDK 7.0 params are passed to JDK 6.0 compiler. The executable requires fork=”true”. On the … Read more

Size of Initialisation string in java

The length of a String literal (i.e. “…”) is limited by the class file format’s CONSTANT_Utf8_info structure, which is referred by the CONSTANT_String_info structure. CONSTANT_Utf8_info { u1 tag; u2 length; u1 bytes[length]; } The limiting factor here is the length attribute, which only is 2 bytes large, i.e. has a maximum value of 65535. This … Read more

javac command line compile error: package javax.servlet does not exist

You need to add the path to Tomcat’s /lib/servlet-api.jar file to the compile time classpath. javac -cp .;/path/to/Tomcat/lib/servlet-api.jar com/example/MyServletClass.java The classpath is where Java needs to look for imported dependencies. It will otherwise default to the current folder which is included as . in the above example. The ; is the path separator for Windows; … Read more

javac source and target options

source: The version that your source code requires to compile. target: The oldest JRE version you want to support. Be sure to also set bootclasspath to ensure your program will work on older VMs. From the javac documentation: Cross-Compilation Example The following example uses javac to compile code that will run on a 1.6 VM. … Read more