background preloader

Java

Facebook Twitter

Compiling and Running Java Programs. Compiling Java Source Code Before the Java virtual machine (VM) can run a Java program, the program's Java source code must be compiled into byte-code using the javac compiler.

Compiling and Running Java Programs

Java byte-code is a platform independent version of machine code; the target machine is the Java VM rather than the underlying architecture. To compile a Java source code file Foo.java, you would do the following: % javac -g Foo.java The -g command line option is optional, but we recommend using it as it makes debugging easier.

If there are no errors in your source file, the Java compiler will produce one or more .class files (one .class file for each class defined in the Foo.java source file). Every public class that you write must be in a separate .java file where the first part of the file name is identical to the class name. Java. Explore JAR files' countless possibilities. The Java Boutique: Free Java Applets, Games, Programming Tutorials, and Downloads - Applet Categories. Use static imports rarely. Static imports allow the static items of one class to be referenced in another without qualification.

Use static imports rarely

Used indiscriminately, this will likely make code more difficult to understand, not easier to understand. Example import java.util.*; import static java.util.Collections.*; public final class StaticImporter { public static void main(String... aArgs){ List<String> things = new ArrayList<>(); things.add("blah"); List<String> syncThings = synchronizedList(things); } } An example in which a static import is likely acceptable is a constants class.

For example, a scientific or engineering application might make wide use of Math.PI. More generally, a business application might define a constants class, and import it statically. Concurrency « Distributed World. Write thread-safe servlets. If you write Web applications in Java, the servlet is your best friend.

Write thread-safe servlets

Whether you write Java ServerPages (JSP) or plain servlets, you are both at the servlet's mercy and the lucky recipient of what the servlet has to offer. So let's look closer at the servlet. As we know, when building a Website, we are primarily interested in the servlet's two methods: doPost() and doGet(). The underlining method for both methods is service(). Later, I look closer at these methods and how they relate to thread safety, but first let's review the concept of a thread.

A thread is a single execution process; in other words, an individual, sequential flow of control within a program. So what do we mean by thread-safe, you ask? What happens when Thread-A examines variable instanceVar? Your servlet container is no dummy A lot of magic happens between the Web browser's HTTP request and the code we write within the doGet() and doPost() methods. Are you thread-safe? Your first defense: Avoidance. DevX: Latest Java Articles - powered by FeedBurner. Archive: Java[tm] Technology Products Download. The Oracle Java Archive offers self-service download access to some of our historical Java releases.

Archive: Java[tm] Technology Products Download

WARNING: These older versions of the JRE and JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production. For production use Oracle recommends downloading the latest JDK and JRE versions and allowing auto-update. Only developers and Enterprise administrators should download these releases. Downloading these releases requires an oracle.com account.

For current Java releases, please consult the Oracle Software Download page. Current update releases for JDK 6 and JDK 7 are available for support customers. For more information on the transition of products from the legacy Sun download system to the Oracle Technology Network, visit the SDLC Decommission page announcement.

Javascript

SSL Connection with Java « Ady Wicaksono Daily Activities. Here is an example Java code to create SSL connection between you and HTTPS (taken from You can compile & run it: $ javac HTTPSClient.java $ java HTTPSClient login.yahoo.com But wait, if HTTPS server give you certificate which is signed by “unknown” Certificate Authority ( I mean not signed by approved CA like Thawte, Verisign) then you will get this error.

SSL Connection with Java « Ady Wicaksono Daily Activities

Detect internet Connection using Java.