Friday, October 12, 2007
Java Faqs - Will Java Allow Viruses and Destructive Programs to be Transmitted Via the Net?
By
Shantan Nethikar
9949040106
Java Faqs - How Fast is Java?
By
Shantan Nethikar
9949040106
Java Faqs - What are the naming conventions in Java?
1 . Package names are guaranteed uniqueness by using the Internet domain name in reverse order: com.javasoft.jag - the "com" or "edu" (etc.) part used to be in upper case, but now lower case is the recommendation.2 . Class and interface names are descriptive nouns, with the first letter of each word capitalized: PolarCoords. Interfaces are often called "something-able", e.g. "Observable", "Runnable", "Sortable".3 . Object and data (field) names are nouns/noun phrases, with the first letter lowercase, and the first letter of subsequent words capitalized: currentLimit.4 . Method names are verbs/verb phrases, with the first letter lowercase, and the first letter of subsequent words capitalized: calculateCurrentLimit.5 . Constant (final) names are in caps: UPPER_LIMIT. Other sites:6 . Check out the section "Naming Conventions" in the language specification: 7. Also take a look at Doug Lea's draft coding standards:
Java Faqs - How can I store the errors from the javac compiler in a DOS file?
javac foo.java > errorfile doesn't work.
javac writes errors to stderr, The problem is that DOS doesn't allow stderr to be redirected (as command.com is very poor software). So you have to use a special error redirection mechanism in the compiler:
javac -J-D javac.pipe.output=true myfile.java > errors.txt
In JDK 1.2, you can use: javac -Xstdout You typically use this when a compilation produces a lot of errormessages, and they scroll off the DOS window before you can read them.
Alternatively, you can get a scollbar to appear on a DOS window by changing the properties with the "Layout" tab. Change the Screen Buffer Size Height: to some multiple > 1 of the Window Size Height. E.g. use a buffer height of 100 and screen height of 25 (the default). This will give you three buffers of scroll "history."
Java Faqs - How do I turn off the JIT in the JDK?
In JDK 1.1.x you use the commandline option "-Dnojit". In JDK 1.2/2 you use "-Djava.compiler=none"
One reason for turning off the JIT is to get more information about any exception that is thrown in your code.
ByShantan Nethikar
9949040106
Java Faqs - What language is the Java compiler and JVM written in?
Java Faqs - Can I compile group of java files once?
The first way isjavac *.java
Another way isjavac -depend tip.java
where "tip.java" is a class "at the tip of the iceberg", i.e. that depends on (uses) all the other classes. Typically, this may be your main class. However, "-depend" is known to be buggy and cannot be relied upon. It also doesn't issue compile commands in parallel to make use of multi-processor systems.Without the "-depend" option, the standard "javac files" doesn't look beyond the immediately adjacent dependencies to find classes lower down the hierarchy where the source has changed.The -depend options searches recursively for depending classes and recompiles it. This option doesn't help when you have dynamically loaded classes whose names cannot be determined by the compiler from the dependency graph. E.g. you use something likeClass.forName(argv[0]);The author of the code using those classes should make sure that those classes are mentioned in a Makefile.
By Shantan Nethikar