Well jdk7.0 is about to be released with few more changes and cool features.
=>Algorithm for Garbage Collector in this version of Jdk is such that it more efficient and takes less pause time.
So program execution is faster.They call it to be First GC.
=>Also swings has been made better by providing even more API.
=>There is a mechanism introduced to make 64 bit pointer compressed and fitted in 32 bit, this reduces the memory requirements and performance.
=>Implementation of standard Elliptic-curve cryptography (ECC) for making java application use ECC out of box.
=>Unicode has been upgraded to 5.1.
=>There are many new API introduced for IO operations.
=> Attempt has been made to make the language as Modularize as possible.
=>Changes in the loader class,here they have provided a method which closes the resources which might be any file and other stuff.
Showing posts with label Java/J2ee. Show all posts
Showing posts with label Java/J2ee. Show all posts
Monday, July 5, 2010
Sunday, July 4, 2010
What's the difference between web server and application server
When it comes the web servers they can process HTTP requests and the main job of these servers is to just send the response for the request received from web browser in the static form (may be Html,images etc) or send a redirect or delegate the response to other program like CGI, JSP(JavaServer Pages) ,server side JS.
Hence Web servers do not have the capability of the executing any business logic Its job is to just get the request serve the request and send the response back.This results in lot of draw backs, which includes application scalability problem,session management
Whereas in Application servers, you can put in business logic for which would be executed by the server for the use of client program.This is mainly done by means of whats called EJB(Enterprise Java Beans).
Also its interesting that Application servers are the super set of the Web servers and hence Application server is capable of doing what web servers do(only allocating resources).
Its important to note that Application server clients can also be GUI running on PC and other Application server.
Hence Web servers do not have the capability of the executing any business logic Its job is to just get the request serve the request and send the response back.This results in lot of draw backs, which includes application scalability problem,session management
Whereas in Application servers, you can put in business logic for which would be executed by the server for the use of client program.This is mainly done by means of whats called EJB(Enterprise Java Beans).
Also its interesting that Application servers are the super set of the Web servers and hence Application server is capable of doing what web servers do(only allocating resources).
Its important to note that Application server clients can also be GUI running on PC and other Application server.
Thursday, January 21, 2010
Implicit objects in JSP
Well when it comes to Java Server Pages(JSP),the most important concept is "implicit objects".
What are implicit object basically? These are the objects that are created by JSP container (server) and you do not need to explicitly create these objects.
There are basically 9 implicit object as listed bellow(along with the corresponding API)
API implicit object
JspWriter ==> out
HttpServletRequest ==> request
HttpServletResponse ==>response
HttpSession ==>session
ServletContext ==> application
ServletConfig ==> config
Throwable ==> exception
PageContext ==> pageContext
Object ==> page
Well looking at the list of API we make out that these are the objects which basically give JSP the servletness features.Well if you are good at servlet than JPS is not that hard and so the "implicit objects".
Friday, August 7, 2009
knowing class file content using javap command....
Well as we know that there is lots of discussion done when it comes to memory allocation for the String class Objects.As we have the concept of "constant pool" and "non-constant pool",the allocation of memory is quit different and really gets confusing some times.
Even in the scenarios like using String class and StringBuffer class,we all know that its better to use the StringBuffer object compared to that of String class as we can append some string despite of concatinating it,we do not actually know why its better but we implement it that way only.
We can obtain the best possible solution to these problems if we can see the bytecode generated after translation of the .java file to .class file.
Well java is not behind even in this aspect of it.Sun has provided a great tool called "javap" command.
Now what javap command does is,it takes the .class file name and prints the information about the class:access specifers,method signature,classes used with fully qualified package...
Also if you use option c with this command we get a different representation....
what it does??well it does not decompile the bytecode but it disassembles the code and gives the bytecode instruction specified by the java virtual mechine.....
Well take a look at this example....String class objects for constant and non constant pool.....
package com.lara;
public class Example
{
public static void main(String[] args)
{
}
void usingStringConstantPool()
{
String s = "java";
s = s+"geek";
System.out.println(s);
}
void usingStringNonConstantPool()
{
String s1 = new String("java");
s1 = s1+"geek";
System.out.println(s1);
}
}
now see this,what happens next...
E:\classFiles\com\lara>javap -c Example
Compiled from "Example.java"
public class com.lara.Example extends java.lang.Object{
public com.lara.Example();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."":()V
4: return
public static void main(java.lang.String[]);
Code:
0: return
void usingStringConstantPool();
Code:
0: ldc #2; //String java
2: astore_1
3: new #3; //class java/lang/StringBuilder
6: dup
7: invokespecial #4; //Method java/lang/StringBuilder."":()V
10: aload_1
11: invokevirtual #5; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
14: ldc #6; //String geek
16: invokevirtual #5; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
19: invokevirtual #7; //Method java/lang/StringBuilder.toString:()Ljava/lang/String;
22: astore_1
23: getstatic #8; //Field java/lang/System.out:Ljava/io/PrintStream;
26: aload_1
27: invokevirtual #9; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
30: return
void usingStringNonConstantPool();
Code:
0: new #10; //class java/lang/String
3: dup
4: ldc #2; //String java
6: invokespecial #11; //Method java/lang/String."":(Ljava/lang/String;)V
9: astore_1
10: new #3; //class java/lang/StringBuilder
13: dup
14: invokespecial #4; //Method java/lang/StringBuilder."":()V
17: aload_1
18: invokevirtual #5; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
21: ldc #6; //String geek
23: invokevirtual #5; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
26: invokevirtual #7; //Method java/lang/StringBuilder.toString:()Ljava/lang/String;
29: astore_1
30: getstatic #8; //Field java/lang/System.out:Ljava/io/PrintStream;
33: aload_1
34: invokevirtual #9; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
37: return
}
now the stuff that you see is more of the JVM specified instructions,so we won't go to that part but we can really make out from the out put that there is new operator being used by the second function twice hence 2 objects are created whereas in first case there is only one object created....
and that's perfectly fine with the theory about these....
But what a command,we can really have own proof of what exactly happens.....
There are other options also available..you can go through the API....one more interesting option is l which prints the local variable and out line table...
Friday, July 31, 2009
Is it that we should always use preparedStatement???(statement vs preparedStatement)
Well when it comes to the competition between preparedStatement and the statement object in JDBC,most of the time its preparedStatement that wins the game....
Reason being simple and not suppressing....
1:)Performance
2:)Efficiency
Actually when we get the statement object from connection object in JDBC there are three things that are done on DB side "FOR EVERY RUN OF THE JAVA PROGRAM"...
#1:The database query is first compiled
#2:there is a query plan that is generated by the database manager
#3:than at last we have the query being executed...
Now if we consider the case of the preparedStatement,than at the first run or execution of the program there is all the three steps that are carried out..but for the subsequent running of the program there will only be the last step that is carried out...
That's because the compiled query and the execution plan is already there with the DB...
Well than whats the use of having the statement object????
the prepapredStatement is considered to the static object...as there is only one type of query that you can possible execute with it....
Whereas in case of the statement object it considered to be the dynamic object as you can execute multiple query from one statement object.....
Thursday, July 30, 2009
Enabling JavaScript.....
Well i can across this question when i was attending a conference in the college......"what happens if you disable the javascript in the web browser"...well nothing like rocket science,answer would be u wont be getting the javascript part(or rather code) of the application being executed....as you have disabled the javascript in the run time environment....
well i was thinking what if we possibly can enable the javascript thought javascript...
Reason for this to be done is simple...as we type the url of any site in the address bar there is this complete html and JS code being downloaded there which than is executed by the browser....Now if i could write a code that can enable JS so that my JS code is executed at run time, will make sure that security feature i.e. authentication is enabled at the client side...
This really sounds like crap as the javascript is disabled from the run time environment how can first off all the JS code be executed....Quit funny:)
but what about the reverse part of it.....well disabling javascript is by using JS is not possible...
reason sounds quit simple...the security is compromised....
well its quit funny to get this kind of thoughts some times...
Saturday, January 31, 2009
Resolve Most Common Bugs When You Code (Java)
I have been reading lots of blogs and exploring lots of sites, but could not find much about the most common real time bugs and solutions at one place. So here comes my experiences one by one (simple ones to more complex) which I have earned with my almost 4 years of software industry experiences.
When you start learning java, first thing you do install the java and set the classpath. Since the classpath has been set, at command prompt if you shoot java or javac command it will be presented with the command options irrespective of the path from where you are shooting, in fact this is the way you check wheather the classpath has been successfully set.
I remember during my college days, I faced the problem where I was not able to set the classpath. First I have installed the JDK and opened the command prompt, tried to run the java and javac command. Since the classpath has not been set, it was not recognized as a external or internal command. Now I have set the classpath and at the same command prompt, I tried to run java commands again the result was the same.
Was that the OS problem or something wrong with my declarations?
Any guesses? ?????????
The reason is simple when you open the command prompt, it takes account of the classpath and provides the memory to run the command. Now the catch is if you modify the classpath and do not open the new command window to run java command and try to run with the same old command window it considers the same old classpath again.
So everytime you modify the classpath, open the new command window is always the best possible option.
Few more tips on classpth....coming soon :))
With how to write the web service to transfer the files across any geographical location over the internet using server client mechanism....:))))))))))))))
Till then enjoy...................
When you start learning java, first thing you do install the java and set the classpath. Since the classpath has been set, at command prompt if you shoot java or javac command it will be presented with the command options irrespective of the path from where you are shooting, in fact this is the way you check wheather the classpath has been successfully set.
I remember during my college days, I faced the problem where I was not able to set the classpath. First I have installed the JDK and opened the command prompt, tried to run the java and javac command. Since the classpath has not been set, it was not recognized as a external or internal command. Now I have set the classpath and at the same command prompt, I tried to run java commands again the result was the same.
Was that the OS problem or something wrong with my declarations?
Any guesses? ?????????
The reason is simple when you open the command prompt, it takes account of the classpath and provides the memory to run the command. Now the catch is if you modify the classpath and do not open the new command window to run java command and try to run with the same old command window it considers the same old classpath again.
So everytime you modify the classpath, open the new command window is always the best possible option.
Few more tips on classpth....coming soon :))
With how to write the web service to transfer the files across any geographical location over the internet using server client mechanism....:))))))))))))))
Till then enjoy...................
ATUL PATEL
Tuesday, January 27, 2009
what is CAFEBABE????

Yesterday when i was going through my classFiles folder which basically contains all of my .class files i found that some of the .java files(source programs) were missing so i was running all those .class files to which i didn't have the source file.....Meanwhile I got this thought as to what will happen if any of these files were not compiled and converted to a .class file by JVM...So i just opened text editor and typed some crap and saved it as ajay.class in my classFiles folder...
Now when i run this file i got an error which looks like "Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 218784115 in class file ajay"...Now according to the API the ClassFormatError is a part of java.lang package(can even be seen from the message printed through console object)and is Thrown "when the Java Virtual Machine attempts to read a class file and determines that the file is malformed or otherwise cannot be interpreted as a class file"...now the ClassFormatError is quite obvious but what's interesting are the last few words "magic value" what is it???? and the answer was quite interesting...Every class file which is compiler by JVM must have the first 4 bytes as "CAFEBABE" which bacisally is to tell the JVM that the class file is a valid one....i was more curious to know why it was 0xCAFEBABE and not something else......after doing little RnD i came up with a lot of stuff but none of them could make me 100% confident that i found the right answer,some of the answers were.....
- some people say that its easier to represent in 32bits format
- some say that there is no j or v in the hexadecimal so they came up with 'CAFEBABE'
And its quite intersecting to know this fact isn't it!!!!!!!!
A tuitorial on how to use ecllipse..An IDE is coming up next
Till then enjoy the world of JAVA!!!!
AJAY:)
Wednesday, January 21, 2009
Whats new in JDK 1.6
There is a lot of cool stuff that has been added in the jdk 1.6.This includes the console applications you can create an object to the console class and can do console related stuff.....This object is only help full when you are basically using a command prompt for running a java program.....in case of eclipse the console object has got nothing to do..and also for a particular command prompt there will be only one console object that's created,this console object lets you do operations as reading a user name and a password from the console by not allowing the user to see the password typed which can be done by using readPassword() method which returns the character array.This was one of the applications that was supported by C but not by java...like wise there are lot of new features been added in this version...you can find new stuff even in the collection API....several new methods have been added to make the things much more easier for the user....this includes the methods added in the list stream(and in fact almost all such as map,set and queues) of the collection API...
Ajay :)
Ajay :)
Subscribe to:
Posts (Atom)