Compiling Source Files with JAV Extension Myth in Java Language Spec 3.0
Get link
Facebook
Twitter
Pinterest
Email
Other Apps
I' ve read something interesting about java source file extensions at Top level type declarations section in java langugae specification 3.0.
When packages are stored in a file system (§7.2.1), the host system may
choose to enforce the restriction that it is a compile-time error if a type is not
found in a file under a name composed of the type name plus an extension (such
as .java or .jav) if either of the following is true: • The type is referred to by code in other compilation units of the package in
which the type is declared. • The type is declared public (and therefore is potentially accessible from
code in other packages).
While in this paragraph is mentioning about top level type class declarations and source file naming conventions; it is pointing that the java source files could be with file extensions .jav. Immediately, i tried with a sample demo class with name Demo.jav.
Demo.jav
public class Demo {
@Override
public String toString() {
return super.toString() + "\tI am Demo class with jav extension";
}
}
The output is not a surprise and disappointed me :) the source file name is detected as a javac command line flag...
H:\jav source>javac -verbose Demo.jav
javac: invalid flag: Demo.jav
Usage: javac
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath Specify where to find user class files
-cp Specify where to find user class files
-sourcepath Specify where to find input source files
-bootclasspath Override location of bootstrap class files
-extdirs Override location of installed extensions
-endorseddirs Override location of endorsed standards path
-d Specify where to place generated class files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J Pass directly to the runtime system
I' ve been already using SoapUI Pro 3.6.1 since license expires. Previous migrations to soapUI newer versions had not caused problems but when starting using SoapUI 4.5.0(free) version resulted destroying existing projects. I checked log file ("C:\...\SmartBear\soapUI-4.5.0\bin\soapui.log") and realised that something went wrong about encoding of soapUI project XMLs. Turkish language characters in wsdl files are located in soapUI project XMLs and they are violating cp1254 character convention and causes below exception log. java.io.CharConversionException: Malformed UTF-8 character: 0xc5 0x3f at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(UTF8XMLDecoder.java:80) at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(XMLStreamReader.java:762) at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(XMLStreamReader.java:162) at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(PiccoloLexer.java:3474) at org.apac
The below exception trace occurs when trying to select records from database to create an instance of an entity or collection of entities. As a result of not providing default constructor on the entity class. I gave a sample entity implementation that has a constructor with string parameter and commented out default constructor. After running iBatis with Spring's framework, iBatis cannot find the default constructor and print the example stack trace. This is also pointing the basics of entity beans in Java EE, "Entity Beans must have a public default constructor". TRACE [2011-12-22 10:28:23,863] 00000522 DEBUG java.sql.Connection - {conn-100087} Preparing Statement: SELECT * FROM DEMO.SAMPLE_TABLE WHERE ID = ? [2011-12-22 10:28:23,863] 00000522 DEBUG java.sql.PreparedStatement - {pstm-100088} Executing Statement: SELECT * FROM DEMO.SAMPLE_TABLE WHERE ID = ? [2011-12-22 10:28:23,863] 00000522 DEBUG java.sql.PreparedStatement - {pstm-100088} Parameters: [1
In order to create operating system processes (even another java application), running a command, and defining an environment variable; a simple approach is succeeded by using " java.lang.ProcessBuilder " class in Java . Process process = Runtime.getRuntime().exec("cmd /c java -cp bin B"); BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while( (line = inputStream.readLine()) != null) { // inputStream is enabling this thread(main method) // to read "System.out" prints of started process (B.main method) System.out.println("#read from inputStream: " + line); } The above example illustrates how to start a java application from another one. /c option has vital importance since the rest of the parameters that command line is fed to run them properly. java command must be in environment variables to run B (which consists the " main(String[] args) " method) and -cp is sta