Thursday, August 26, 2010
RIA –Rich Internet Applications
•Web 2.0
–Internet as a platform
–Hosted services, social networking, wikis, RSS, RIA, …
•Cloud computing
–Apps run somewhere in the "cloud" (intranet or Internet)
•RIA (rich internet apps)
–Web apps which look and perform like desktop apps
•JavaScript
–Not as lame as it once was; optimization in new browsers
•Offline, desktop integration
–Enabling Web apps to run offline
•Mashup
–Web app that combines data from multiple sources into a single tool
•HTML 5.0
–Not coming any time soon
Rich internet applications (RIA)
•Two primary technologies
–JavaScript(AJAX)
•Built-in browser support
– Google AJAX APIs
–jQuery, Prototype, script.aculo.us, MooTools, Dojo,…
– Yahoo! User Interface Library(YUI)
–ASP.NET AJAX
–Virtual machines(plug-ins)
•Require installation (plug-in/runtime)
– Gears
–Java/ JavaFX
– Flash/ Flex
– Curl
– BrowserPlus
– Silverlight
RIA technologies from Google,sun,adobe,yahoo,microsoft
Google RIA
-Google Web Toolkit(GWT)
-Gears(google Gears)
Sun RIA
-JavaFx
Adobe RIA
-Flex
-AIR(Adobe Integrated runtime)
Mozilla RIA
-Prism
Yahoo RIA
-broswerPlus
Microsoft RIA
-Silverlight
Wednesday, August 25, 2010
What is agile scrum (sprint) process
In Scrum,project are divided in small features to be developed and tested in specific time-frames called as Sprint(small cycles)
Scrum is an iterative, incremental framework for project management and agile software development process
--------------------------------------------------------------------------------------------------------
The SCRUM Process –software development process

Planning
In this phase, the project is planned and high-level design decisions are made.

The sprint cycle is repeated until the product's development is complete. The product is complete when the variables of time, quality, competition, and cost are at a balance.
- Develop the product further - implement, test, and document.
- Wrap up the work - get it ready to be evaluated and integrated.
- Review the work done in this sprint.
- Adjust for any changes in requirements or plans.
Closure
In this phase, the product's development is brought to a close, and the product is released.
start() method vs run() method in Java
start method
public void start() - this method is responsible for causing the thread (it's called upon) to begin execution. The name may seem to be a misnomer here as this method only causes and not actually starts the execution. It just schedules the thread and when the CPU Scheduler picks this thread for excution then the JVM calls the run() method to actually start the execution of the thread.
This method will obviously result into two concurrent threads - one, from which this method is called and two, the new thread which executes the run() method of the new Thread instance.
A thread will throw IllegalStateException in case you try to call the start() method on an already started thread instance. That means, a thread can not be started more than once. As per the Java specifications a thread may not be restarted after completing its execution. You'll be required to create and start the execution of a new thread in that case.
run method
public void run() - this is the only method of the Runnable interface and the classes which intend to execute their code in a separate thread of execution first implement the Runnable interface and subsequently define this method and put all the code expected to be executed in the separate thread inside the scope of this run method.
The other way, such classes can follow for the same is by extending the Thread class and in that case also they should oevrride the run method of the Thread class and put all the code supposed to be executed in the new thread inside the scope of the overriden run method.
Difference between start() and run() methods
start() methods only schedules the thread for execution and not actually begins the execution of the thread. The execution of the thread is started when the JVM calls the run() method of the thread once the CPU Scheduler picks this scheduled thread for execution.
Systems Development Life Cycle
Systems Development Life Cycle ¶
SDLC -Systems Development Life Cycle
SDLC in systems engineering, information systems and software engineering
SDLC: Analysis -> Design -> Implementation -> Testing -> Maintenance
SDLC -phases
1.requriement gathering and analysis
2.design
3.build or coding
4.Testing
5.operation and Maintenance
SDLC- methodologies
concept underpins many kinds of software development methodologies.
1.Waterfall Approach
2. Prototyping Approach
3. Incremental Approach
4. Spiral Approach
5. Rapid Application Development (RAD) Approach
6.Other software development practices and techniques
> Object oriented
> Top-down programming
> Unified Process (UP)
> Agile Software Development
> Integrated Software Development(iterative, waterfall, spiral, agile)
methodologies for waterfall ,prototyping,spiral
Software testing
Software testing is an investigation conducted to provide stakeholders with information about the quality of the product or service under test.
Test techniques include, but are not limited to, the process of executing a program or application with the intent of finding software bugs.
Software testing can also be stated as the process of validating and verifying that a software program/application/product.
Different software development models will focus the test effort at different points in the development process. Newer development models like
> Agile development
> Employ test driven development
Testing methods
The box approach
1.White box testing
2.Black box testing
3.Grey box testing
Testing levels
1.Function level
2.Non -Function level
Functional testing
Functional testing is done using the functional specifications provided by the client or by using the design specifications like use cases provided by the design team.
· Unit Testing
· Smoke testing / Sanity testing
· Integration Testing (Top Down,Bottom up Testing)
· Interface & Usability Testing
· System Testing
· Regression Testing
· Pre User Acceptance Testing(Alpha & Beta)
· User Acceptance Testing
· White Box & Black Box Testing
· Globalization & Localization Testing
Non-Functional Testing
Non-Functioning testing is done based on the requirements and test scenarios defined by the client.
· Load and Performance Testing
· Ergonomics Testing
· Stress & Volume Testing
· Compatibility & Migration Testing
· Data Conversion Testing
· Security / Penetration Testing
· Operational Readiness Testing
· Installation Testing
· Security Testing (Application Security, Network Security,System Security)
The testing process
> Traditional CMMI or waterfall development model
> Agile or Extreme development model
Automated testing
> Testing tools (Ant, Maven)
Measurement in software testing
Usually, quality is constrained to such topics as correctness, completeness, security,but can also include more technical requirements as described under the ISO standard ISO/IEC 9126, such as
>capability
>reliability
>efficiency
>portability
>maintainability
>compatibility
>usability
Wednesday, August 18, 2010
java return String array[] to String
public void m1(){
String name=m2()[1];
System.out.println("my name is:"+name);
}
public static String[] m2(){
String[] val={"karthik","thiyagu","gogul"};
return val;
}
public static void main(String[] args) {
new new1().m1();
}
output:
my name is:thiyagu
JSON- JSONObject and JSONArray example
import net.sf.json.JSONArray;
public class FirstJSON {
public static void main(String[] args) {
System.out.println("----------JSON Object-------------------");
JSONObject obj=new JSONObject();
obj.put("name", "karthik");
obj.put("age", "24");
System.out.println(obj);
System.out.println("----------JSON Array-------------------");
JSONArray arr=new JSONArray();
arr.add("name");
arr.add("karthik");
arr.add("age");
arr.add(24);
System.out.println(arr);
}
}
output:
----------JSON Object-------------------
{"name":"karthik","age":"24"}
----------JSON Array-------------------
["name","karthik","age",24]
Tuesday, August 17, 2010
JSON-JavaScript Object Notation
It is easy for humans to read and write. It is easy for machines to parse and generate.
It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.
JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
eg:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
The same text expressed as XML:
< id="file" value="File">
<>
< value="New" onclick="CreateNewDoc()">
< value="Open" onclick="OpenDoc()">
< value="Close" onclick="CloseDoc()">
< /popup>
< /menu>
string split using java
delimiter -" " | "-" | ", " | "6"
String str = "one-two-three";
String[] temp;
String delimiter = "-";
temp = str.split(delimiter);
for(int i =0; i < temp.length ; i++)
System.out.println(temp[i]);
-------------------------------------------------------------------------------------------
note: IMPORTANT : Some special characters need to be escaped while providing them as
delimiters like "." and "|".
str = "one.two.three";
delimiter = "\\.";
temp = str.split(delimiter);
for(int i =0; i < temp.length ; i++)
System.out.println(temp[i]);
/*
#
Using second argument in the String.split() method, we can control the maximum
#
number of substrings generated by splitting a string.
# */
temp = str.split(delimiter,2);
for(int i =0; i < temp.length ; i++)
System.out.println(temp[i]);
output
one
two
three
------
one
two.three
Compiling a Simple Program with directory structure
Hello.java
, defines a class called greetings.HelloC:> dir
greetings/
C:> dir greetings
Hello.java
package greetings;
public class Hello {
public static void main(String[] args) {
for (int i=0; i < args.length; i++) {
System.out.println("Hello " + args[i]);
}
}
}
C:> javac greetings\Hello.java
C:> dir greetings
Hello.class Hello.java
C:> java greetings.Hello thiyagu karthik
Hello thiyagu
Hello karthik
Compiling Multiple Source Files
C:> javac greetings\*.java
Friday, August 13, 2010
Copy one file to another using java File,BufferedReader,BufferedWriter
import java.io.*;
import java.util.*;
public class CopyTextFile {
public static void main(String args[]) {
//... Get two file names from use.
System.out.println("Enter a filepath to copy from, and one to copy to.");
Scanner in = new Scanner(System.in);
//... Create File objects.
File inFile = new File(in.next()); // File to read from.
File outFile = new File(in.next()); // File to write to
//... Enclose in try..catch because of possible io exceptions.
try {
copyFile(inFile, outFile);
} catch (IOException e) {
System.err.println(e);
System.exit(1);
}
}
//=============================================================== copyFile
// Uses BufferedReader for file input.
public static void copyFile(File fromFile, File toFile) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fromFile));
BufferedWriter writer = new BufferedWriter(new FileWriter(toFile));
//... Loop as long as there are input lines.
String line = null;
while ((line=reader.readLine()) != null) {
writer.write(line);
writer.newLine(); // Write system dependent end of line.
}
//... Close reader and writer.
reader.close(); // Close to unlock.
writer.close(); // Close to unlock and flush to disk.
}
//=============================================================== copyFile2
// Uses Scanner for file input.
public static void copyFile2(File fromFile, File toFile) throws IOException {
Scanner freader = new Scanner(fromFile);
BufferedWriter writer = new BufferedWriter(new FileWriter(toFile));
//... Loop as long as there are input lines.
String line = null;
while (freader.hasNextLine()) {
line = freader.nextLine();
writer.write(line);
writer.newLine(); // Write system dependent end of line.
}
//... Close reader and writer.
freader.close(); // Close to unlock.
writer.close(); // Close to unlock and flush to disk.
}
}
File, BufferedReader,BufferedWriter using java
File toFile=new File("myout.txt");
BufferedReader br=new BufferedReader(new FileReader(fromFile));
BufferedWriter bw=new BufferedWriter(new FileWriter(toFile));
String line = null;
while ((line=br.readLine()) != null) {
bw.write(line);
bw.newLine(); // Write system dependent end of line.
}
br.close();
bw.close();
Thursday, August 12, 2010
Behavior of PuTTY pscp recursive directory copy different from that of scp?
the entire "temp" directory to a server (Red Hat Enterprise Linux 4)
using pscp from PuTTY 0.60:
C:\temp\dir1\a.txt
C:\temp\dir2\b.txt
Scenario 1: if there is a trailing slash (or backslash) in the source
path, only the content of "temp" is copied:
C:\>pscp -r temp/ karthik@xxxxxxxxxxxx:/home/karthik/test/
On the server:
/home/karthik/test/dir1/a.txt
/home/karthik/test/dir2/b.txt
Scenario 2: if there is no trailing slash in the source path, the
entire "temp" is copied:
C:\>pscp -r temp michael@xxxxxxxxxxxx:/home/karthik/test/
On the server:
/home/karthik/test/temp/dir1/a.txt
/home/karthik/test/temp/dir2/b.txt
Doing a similar action from a Linux machine to the same server, with
or without the trailing slash, the result of scenario 2 is obtained.
.properties or .ini file read and write using java
DBuser=anonymous
DBpassword=&8djsx
DBlocation=bigone
--------------------------------------------------------------------
class ReadandWrite {
public static void main(String args[]) {
ReadandWrite props = newReadandWrite();
props.readit();
props.writeit();
}
public void readit() {
try{
Properties p = new Properties();
p.load(new FileInputStream("user.properties"));
System.out.println("user = " + p.getProperty("DBuser"));
System.out.println("password = " + p.getProperty("DBpassword"));
System.out.println("location = " + p.getProperty("DBlocation"));
p.list(System.out);
}
catch (Exception e) {
System.out.println(e);
}
}
public void writeit() {}
try{
Properties p = new Properties();
p.load(new FileInputStream("user.properties"));
p.list(System.out);
// new Property
p.put("today", new Date().toString());
// modify a Property
p.put("DBpassword","foo");
FileOutputStream out = new FileOutputStream("myuser.properties");
p.save(out, "/* properties updated */");
}
catch (Exception e) {
System.out.println(e);
}
}
java best way to do program
public static void main(String[] args) {
new ReadandWrite().readIt();
new ReadandWrite().writeIt();
}
private void readIt()
{
try {
}catch(){ }
}
private void writeIt()
{
try {
}catch(){}
}
} //end of the class
Wednesday, August 11, 2010
Java Configuration Files
The syntax for a .properties file could not be simpler; all lines beginning with a # are comments and all other lines are in the form:
CODE:
1.
< key>= < value>
Below is a sample configuration for the Virtual Learning environment
CODE:
1.
# Basic portal config
2.
BASE_URL=www.eve.nuim.ie/evePortal
3.
4.
# Database stuff
5.
DB_JNDI_NAME=jdbc/eve_portal
6.
7.
# File locations
8.
DATA_DIR=/var/eve-data
9.
PDFLATEX_BIN=/opt/local/bin/pdflatex
10.
IMAGEMAGICK_BIN_DIR=/opt/local/bin
If you choose to use this type of configuration file you can locate and open it all in one step by using functionality built into the java class loader as follows:
JAVA:
1.
Properties configFile = new Properties();
2.
configFile.load(this.getClass().getClassLoader().getResourceAsStream("/my_config.properties"));
You can they read out any key in the following way:
JAVA:
1. some_var = configFile.getProperty("some_key");
Simple as that, no need to load complex parsing libraries, no big long messy code. Unless you have a good reason to go with a more complex format you really should be using .properties files.
Properties configFile = new Properties();
configFile.load(new FileInputStream(”configuration.conf”));
String foo = configFile.getProperty(”my_key”);
Monday, August 9, 2010
How to write a Java Application without a main method
The reason this works is that static initialization blocks get executed as soon as the class is loaded, even before the main method is called. During run time JVM will search for the main method after exiting from this block. If it does not find the main method, it throws an exception. To avoid the exception System.exit(0); statement is used which terminates the program at the end of the static block itself.
class MainMethodNot
{
static
{
System.out.println("This java program have run without the run method");
System.exit(0);
}
}
Wednesday, August 4, 2010
Awt, Swing and SWT
SWING: is one of the most complex GUI frameworks ever developed. It has a complete set of GUI components ranging from buttons and text fields to tables, trees, and styled text editors. These components do not rely on the native widgets of the operating system; instead, Swing components are painted using graphic primitives such as lines, rectangles, and text. The painting is delegated to a look and feel (L&F) plug-in that can imitate the native L&F. Swing also has a platform-independent L&F called "Metal." JBuilder, uses Swing, and its speed is quite good.
Standard Widget Toolkit (SWT) is the GUI toolkit developed by IBM for its Eclipse IDE. SWT can be used outside of the Eclipse environment and offers direct access to the native GUI features of the operating system. Therefore, SWT-based Java applications have native GUIs and can be integrated with other native applications and components. SWT delegates to native widgets for common components (such as labels, lists, tables, and so on) as AWT does, while emulating in Java more sophisticated components (for example, toolbars are emulated when running on Motif) similarly to Swing's strategy.SWT has been designed to be as inexpensive as possible. This means (among the other things) that it is native-oriented. Anyway, it differs from AWT in a number of details. SWT provides different Java implementations for each platform, and each of these implementations calls natively (through the Java Native Interface, JNI) the underlying native implementation. The old AWT is different in that all platform-dependent details are hidden in C (native) code and the Java implementation is the same for all the platforms.
Tuesday, August 3, 2010
java.lang » System Properties
* Getting and Setting the Value of a System Property
* Listing All System Properties
* Setting the Value of a System Property from the Command Line
Getting and Setting the Value of a System Property
// Get a system property
String dir = System.getProperty("user.dir");
// Set a system property
String previousValue = System.setProperty("application.property", "newValue");
--------------------------------------------------------------------------------
Listing All System Properties
// Get all system properties
Properties props = System.getProperties();
// Enumerate all system properties
Enumeration enum = props.propertyNames();
for (; enum.hasMoreElements(); )
{
// Get property name
String propName = (String)enum.nextElement();
// Get property value
String propValue = (String)props.get(propName);
}
---------------------------------------------------------------------------------
Setting the Value of a System Property from the Command Line
A system property can be set or overridden by specifying the -D option to the java command when running your program.
java -Dmy.prop="my value" MyApp
// Get the value of the system property
String prop = System.getProperty("my.prop");
// my value
OS' environment variables from within a Java program
public class EnvMap {
public static void main (String[] args) {
Map
for (String envName : env.keySet()) {
System.out.format("%s=%s%n", envName, env.get(envName));
}
}
}