Friday, August 10, 2012
Java Solutions - New Java Platforms or Frameworks for Enterprise Solutions
Friday, April 6, 2012
What is Java Object Initialization?
Object initialization is very important in programming, as it is a common source of bugs. The Java Programming language provides different built-in mechanisms to ensure proper initialization of the memory occupied by a newly-created object, there by helping the objects to get a valid initial state.
The Java Programming language offers three mechanisms to ensure proper initialization of newly created objects.
* Constructors.
* Instance variable initialization.
* Instance initialization.
When we are creating an object using new operator or the new Instance() method of class, JVM allocates memory for it, then Java virtual machine will run the initialization code before we use the newly-allocated memory.
Constructors
Constructors are methods, with a set of parameters and a body of code and has the same name as the class but has no return type. The constructors can be overloaded by varying the number, types, and order of parameters. When we are creating new instance using new keyword we often provide a constructor that initialize the Object. If we are using class that has no constructor defined, the compiler will automatically generate a default constructor for the class. This constructor has no parameter and has empty body, this ensures that each class has at least one constructor.
class Demo
{
int a;
public Demo()
{
// the initialization code for instance variables
a=0;
}
}
Instance variable initialization
In an instance variable initialization method java uses an equals sign and expression technique to initialize the instance variable.
class Demo
{
private int a = 1; //this evaluate a with a value of 1
}
Instance initialization
Instance initialization is also known as instance initialization block, which is one of the alternatives to Instance variable initialization. It is very useful in following situations
* Initializer code need to catch exceptions.
* Initializer code need to do calculations that can't be expressed with an instance variable initializer.
* If class has multiple constructors - no need to repeat the same initializing code in all constructors.
* When we use anonymous inner classes, which normally do not have constructors.
class Demo
{
private int a;
//intializer
{
a=2;
}
}
One of the main properties of initializers is they cant make forward reference, as the initializers are executed in textual order.You have to make sure that the referring of instance variable should be only after it is initialized.
Default initial values
If we are not providing any explicit initialization method to variables including instance and class variables, they will be initialized according to their type. Each data type has its own default initial values. The local variable must be initialized explicitly before use.
e.g boolean-false
int - 0
Java's initialization mechanisms help the programmer to ensure that objects we design have a valid and predictable state.
Article Source: http://EzineArticles.com/4564513
Sapient : Work-from-home is the HR trend that seems to have evolved from IT & ITES firms who mainly leverage on Internet to connect & collaborate with business associates, partners and clients.
New to Java
The new beginners section "New to Java technology" on Roseindia.net, can help the dummies to learn java from basic to masters level.
This new to java tutorial briefs you on following topics.
1. Basics of Java Technology
2. Understanding the Java Technology
3. Why Java Technology is so important?
4. Different Editions of Java Technology
5. Components of each edition
· JSE Components:
· JEE - Components: etc... etc...
How to create and run my first java program, to what extension java file should be saved, java compiler, java and jdbc database connectivity or java with database management system. These are the very common problems raised while learning java.
Here in this new to java section you will find all the required solution to step ahead on next level of java technology.
The Additional features "Java Examples" of New to java tutorial can help you in learning java quickly and easily. As example codes are already written, you only have to copy and paste it to execute and run the program. In this way you can save yourself from writing code and fixing the bugs.
Find out more about java tutorials, struts tutorials and other programming language at Rroseindia.
Take a quick glance of what you can learn here ...
1. Java tutorials: Basic and advance Java to enhance your skills.
2. JSP Tutorials: Java server pages and other scripting language.
3. Spring and Hibernate Tutorials
4. MySql tutorials: Database connectivity by using java and MySql
That's not all, here you will find numerous tutorials on latest programming technology along with running examples and descriptions.
This review new to java has written for the java beginners, at roseindia.net you can read more New to java tutorial, struts tutorial for beginners and professionals to enhance your skills.
Article Source: http://EzineArticles.com/562728
Introduction to Java Concurrent Programming
The last few years, multicore processors have become less expensive. Most desktop computers and laptops are using multicore chips and developers are programming more and more with multiple concurrent threads. A downside is that the bug reports related to threading are also increasing every day; this shows that multicore programming is not the easiest thing to do. In Java, concurrency bugs are one of the most painful problems and in many occasions they are highly unpredictable. One of the biggest issues regarding Java concurrent programming is the mind-set of the programmers that doesn't match the concurrency features offered in Java. Programmers need to start thinking about concurrency and parallelism in the foundation of their programs. The Java language provides low level tools for concurrency such as condition waits, synchronization, message passing and resource sharing. The problem is that these tools need to be implemented at application level consistently. The conclusion? It can already be hard to write correct programs, but writing correct concurrent programs is even harder. The right mind-set is needed. The reason behind the high difficulty level is that there are simply more levels where things can go wrong with Java concurrent programming. The reason developers still choose to use concurrency on their programs is because threads are an inevitable feature of the Java language and the easiest way to use the multicore power we see almost everywhere these days. When looking are the future, the only conclusion that can be made is that concurrency programming will become increasingly important with the rising number of cores.
For more information regarding Java concurrent programming, please visit www.ateji.com.
Article Source: http://EzineArticles.com/6401289
Monday, February 6, 2012
Understand The Java Classpath
This article is about a small simple collection of batch files which can be used to test the behavior of the javac compiler and java class launcher for different classpath scenarios. The system is called ClasspathTester. Download instructions are included at the end of this article.
When you are in the middle of trying to debug a java build it is a bad time to try to boil everything down to a simple test case, so basically the intent of my test collection is to do this for you ahead of time. If you can't find the precise test you need, it is easy to modify the existing tests or create a new test to suit your needs.
How ClasspathTester Works
As previously stated, I did everything with batch files, because I wanted the tests to be as uncomplicated, portable (within the Windows environment), and simple as possible. There are a few helper batch files to do things like create formatted output and build a directory structure, but otherwise nearly all of the work is done in the RunAllTests.bat file.
What RunAllTests.bat consists of is tests and sub-tests. If you haven't downloaded it yet, I suggest you download it and take a look. Each test consists of some sort of a setup. Setup normally involves the following:
1. Test environment is cleaned up of old directories, files, and classpath.
2. New directory structure is created, new files are created and placed in correct directories, and the classpath is set if necessary.
After setup, the tests are run. This consists of running either the javac.exe compiler, the java.exe launcher, or both. That's all there is to it.
A Simple Example
To understand what ClasspathTester, does, open the RunAllTests.bat file in your text editor and look at TEST1. Each test is a collection of sub-tests which are loosely grouped around some kind of a central testing theme, and TEST1 is one of the simplest.
So what happens in Test1? First it calls banner.bat to add a header to the results file. Then it creates the Hello.java and MyLibClass.java files, by copying them from their corresponding avaj files (the reason for using avaj files is discussed later in this article). Now everything is set up to run some subtests.
TEST1A is very simple. According to its description, " The Hello.java file is located in the current directory, and the Hello.class file will be written to the current directory and run from the current directory". As you can imagine, TEST1A operates flawlessly.
TEST1B and TEST1C are designed to show different ways that using java.exe to launch the Hello.class file can fail. In TEST1B the classpath is been set to an empty directory. In TEST1C the file Hello.class is erased. Interestingly, these two tests fail in exactly the same way.
Note that all tests results are stored in the results.log file.
How the Tests are Kept Safe
By "safe" I mean safe to your computer, safe to your other data. Since the tests involve batch files that are creating and destroying files and directories, care must be taken to avoid accidentally destroying or writing over other unrelated files. This is accomplished in the cleanup.bat file by avoiding the use of statements like "erase /S *.*" or "rmdir /S *". Instead, all erasures are kept fairly specific.
In fact, the cleanup.bat file consists of the following statements:
set classpath=
rmdir /S /Q aq
rmdir /S /Q EmptyDirectory
erase Hello*.java
erase Hello*.class
erase MyLibClass*.java
erase MyLibClass*.class
This ensures that there will be no tragic accidental loss of unrelated data.
Why Use .avaj Suffix Files
Part of the operation of ClasspathTester involves completely wiping the base directory clean of all .java files, .class files, and subdirectories; therefore, all the suffix of all permanent java files is mangled to avaj. For any test, the appropriate avaj files are copied to java files. The available files are:
Hello.avaj
Hello1.avaj
Hello2.avaj
MyLibClass.avaj
MyLibClass1.avaj
MyLibClass2.avaj
Download Information
You can find and download a zipped copy of the ClasspathTester can be on my Article Support Page
Summary
ClasspathTester is simple, portable, unobtrusive, customizable and solves an annoying development problem, the need to quickly test special classpath situations with javac.exe, java.exe, or both.
Monday, January 23, 2012
Difference Between Java and WordPress
Java
Java is an enterprise Language, what it means it is used to build enterprise applications, what do we mean by that?
· A variety of clients can interact with applications like browsers, smart tablets, B2B applications, .NET and other language apps.
· High Security to support the standards.
· Highly Scalable to support the growing traffic.
· Performance - Begin compile time performance is high.
· E.g applications are Gaming, ECommerce websites, Billing, Retail, CRM and tons of others
Java can be used to create blogging CMS like WordPress. There are CMS's like alfresco, Plone, JRoller whodo to attempt to that, but none has been able so popular as WordPress.
WordPress
Very specialized CMS/blogging engine build on top of PHP.
· It is very easy to learn software, compare it to learning MS Word.
· You don't need to know PHP/programming to be WordPress website developer.
· It has a themes concept, which allows a developer to configure website pages with easy.
· Supports thousands of plugins, almost easy to find any kind of functionality a website needs.
· Installs on Apache Server with PHP engine.
· Many hosting sites support 1 click install.
· Uses MySQL as the backend engine.
As you see, WordPress and Java cannot be compared as one is a language where another is a software built on PHP language.
Had WordPress been written in Java
As a Java Developer, I do wish WordPress was built on Java, it would have given
1. Java applications a web flair, we would have to see all together new set of applications /widgets/ plugins.
2. Designers would have not been scared of the language at all.
3. Applications could have used the WordPress database, which has a very simple schema.
WordPress And Java Together
Resin Quercus
Resin is a Java Application server, but with a twist, it has a Quercus engine which allow PHP applications to installed as Java applications.
What does this mean, if a WordPress can be installed on Resin will run as a Java application and also take advantage of libraries like Spring, Hibernate,SOA.
Also, will definitely perform way better as it will be compiled only once and not be interpreted with every request like it does now
To have this integration working has its own challenges but good news is there is a way.
Summary
While WordPress has it own niche, creating CMS websites with blog functionality, it is the DeFacto Platform.
But when it comes to creating highly scalable enterprise Applications Java is the DeFacto Platform.
Makarand Bhatamrekar is a enterprise Java RIA Career Coach. He has been coaching since 2007 on Java technologies to help trainees achieve their java career goals. http://careerInJava.com is a dedicated the effort to give all the resources needed to succeed.
To be informed of the latest update, do subscribe the Newsletter at http://www.careerInJava.com
WordPress is the easiest CMS out here, which allows to create your website with no knowledge of PHP. Makarand was able to develop coaching website on WordPress with no prior knowledge of the same, hence this post comparing the two.
Article Source: http://EzineArticles.com/6811651
utvecklare intranet