<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4555712962561805550</id><updated>2025-10-26T18:29:18.553+05:30</updated><category term="20124d"/><title type='text'>Abhishek Mishra </title><subtitle type='html'>A blog for Java lovers</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-4678247206761918012</id><published>2025-02-28T17:33:00.000+05:30</published><updated>2025-02-28T17:33:16.030+05:30</updated><title type='text'>Building a GraalVM Native Image for Linux on Windows Using Docker</title><content type='html'>&lt;h1&gt;&lt;br /&gt;&lt;/h1&gt;
&lt;p&gt;For Windows users seeking to create a GraalVM native image for a Linux environment, traditional approaches such as switching to Linux, dual booting, or using virtual machines can be cumbersome and inefficient. In this guide, we present a streamlined method leveraging Docker, enabling seamless development while retaining your Windows environment.&lt;/p&gt;
&lt;h2&gt;Traditional Methods and Their Challenges&lt;/h2&gt;
&lt;p&gt;Before exploring our Docker-based solution, let&#39;s review common methods and their limitations:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Switching to Linux&lt;/strong&gt; – This approach requires fully migrating to a Linux OS, causing loss of access to Windows-based applications.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Dual Booting&lt;/strong&gt; – Involves partitioning disk space for both Windows and Linux, requiring a reboot each time you switch between operating systems.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Using a Virtual Machine (VM)&lt;/strong&gt; – While providing a Linux environment within Windows, this method demands significant system resources and additional configuration.&lt;/li&gt;&lt;/ol&gt;
&lt;h2&gt;A Modern Solution: Leveraging Docker&lt;/h2&gt;
&lt;p&gt;Using Docker, you can set up an isolated Linux environment within Windows, facilitating native image generation without the need for OS switching.&lt;/p&gt;
&lt;h3&gt;Step 1: Creating an Ubuntu-Based Docker Container&lt;/h3&gt;
&lt;p&gt;To establish an Ubuntu container with Git pre-installed, use the following Dockerfile:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-dockerfile&quot;&gt;&lt;blockquote&gt;# Use the official Ubuntu image as the base
FROM ubuntu:latest

# Set non-interactive mode to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Update package lists and install Git and Wget, then clean up
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y \
    git \
    wget \
    &amp;amp;&amp;amp; apt-get clean \
    &amp;amp;&amp;amp; rm -rf /var/lib/apt/lists/*

# Set the default command
CMD [&quot;/bin/bash&quot;]
&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Step 2: Running the Container and Setting Up GraalVM&lt;/h3&gt;
&lt;ol&gt;&lt;li&gt;Build and run the Docker container:
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;blockquote&gt;docker build -t ubuntu-graalvm .
docker run -it ubuntu-graalvm
&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;Clone your project repository inside the container using Git.&lt;/li&gt;&lt;li&gt;Download and extract GraalVM manually:
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;blockquote&gt;wget https://download.oracle.com/graalvm/23/latest/graalvm-jdk-23_linux-x64_bin.tar.gz
tar -xvzf graalvm-jdk-23_linux-x64_bin.tar.gz
&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;Configure &lt;code&gt;JAVA_HOME&lt;/code&gt; to point to the extracted GraalVM directory.&lt;/li&gt;&lt;li&gt;Build the native image. For a Maven Spring Boot project, use:
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;&lt;blockquote&gt;./mvnw -Pnative native:compile
&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;h3&gt;Step 3: Transferring the Native Image to the Local Machine&lt;/h3&gt;
&lt;p&gt;Once the native image is successfully built, copy it from the container to your Windows system using:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;docker cp &amp;lt;container_id&amp;gt;:/app/project/webfluxtest/target/webfluxtest C:\Users\YourUsername\Documents
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Step 4: Packaging the Native Image in a Linux-Based Container&lt;/h3&gt;
&lt;p&gt;To deploy the native image within a Linux environment, use the following Dockerfile:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-dockerfile&quot;&gt;&lt;blockquote&gt;# Use a minimal Ubuntu base image
FROM ubuntu:latest

# Install necessary dependencies
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y libc6 &amp;amp;&amp;amp; rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy the prebuilt native binary into the container
COPY webfluxtest /app/webfluxtest

EXPOSE 8080

# Set execution permissions
RUN chmod +x /app/webfluxtest

# Define the entrypoint
ENTRYPOINT [&quot;/app/webfluxtest&quot;]
&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Step 5: Building and Running the Final Container&lt;/h3&gt;
&lt;ol&gt;&lt;li&gt;Build the Docker image:
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;docker build -t webfluxtest-native .
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;Run the container:
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;docker run -p 8080:8080 webfluxtest-native
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;At this stage, your GraalVM native image is successfully running within a Linux-based Docker container, all while maintaining your Windows development environment.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;By utilizing Docker, Windows users can efficiently build and deploy Linux-native GraalVM applications without the need for complex system reconfigurations. This approach enhances flexibility, optimizes workflow, and eliminates unnecessary overhead. Start leveraging Docker today for seamless native image development!&lt;/p&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/4678247206761918012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/4678247206761918012' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/4678247206761918012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/4678247206761918012'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2025/02/building-graalvm-native-image-for-linux.html' title='Building a GraalVM Native Image for Linux on Windows Using Docker'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-4386783048991112565</id><published>2017-11-18T15:33:00.000+05:30</published><updated>2017-11-18T15:33:04.429+05:30</updated><title type='text'>java.SQl.Sqlexception:Invalid state, the connection object is closed</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This exception seems to be wired to you are in suspected mode.Whenever you see this Exception below things comes in your mind&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Somebody written bullshit code, Executing query after closing connection object&lt;br /&gt;&lt;br /&gt;&lt;b&gt;what if this is not the case, Then&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;If you are using any ORM framework, then might be ORM doing something&lt;br /&gt;&lt;b&gt;or&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;if you are using SQL driver, then might driver doing something&lt;/li&gt;
&lt;/ol&gt;
Apart from this, there is one more hidden cause which will act secretly on this, if you not aware of that i.e DB Configuration&lt;br /&gt;
let&#39;s take MSSQl DB for exploring thing&lt;br /&gt;
&lt;br /&gt;
In MSSQL server under TCP connection configuration, there is a property is configured called &lt;b&gt;KEEP ALIVE&lt;/b&gt; whose default value is set to &lt;b&gt;30000 milliseconds.&lt;/b&gt;&lt;br /&gt;
Let go in depth of &lt;b&gt;KEEP ALIVE behavior&lt;/b&gt;, what it does.How database reacts to the time configured under KEEP ALIVE.DB expire the idle connection object if it exceeds the time limit configured under kEEP ALIVE.&lt;br /&gt;
&lt;br /&gt;
How this impact on our application.&lt;br /&gt;
In Every application whenever we interact with DB, we will create the connection pool with some minimum count.Let&#39;s get in-depth how connection pool will get impacted with KEEP ALIVE property of DB&lt;br /&gt;
Let&#39;s assume DB connection pool is created with min count 5 and max count 10.While creating connection pool there is one property which is mandatory to know the value of that i.e &lt;b&gt;IdleTime&lt;/b&gt; ( &lt;b&gt;name can vary w.r.t driver, ORM&lt;/b&gt; ), which say up to what time connection can be idle.Now if IdleTime is more that KEEP ALIVE value and connection Object in the pool is idle more than KEEP ALIVE but less then IdleTime, then the connection object in a pool is getting expired from DB server side and when this connection object is used before IdleTime, you will face&amp;nbsp; java.SQl.Sqlexception: Invalid state, the connection object is closed.&lt;br /&gt;
&lt;br /&gt;
So be aware while configuring connection pool. All DB connection pool is supposed to configure w.r.t DB configuration and your application activity like :&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;IdleTime should be always lesser than KEEPALIVE&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;If your application is not much-having heavy traffic then min connection should be in small count like 2 or 3&lt;/li&gt;
&lt;li&gt;Max connection count depends upon how DB accept the connection.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/4386783048991112565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/4386783048991112565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/4386783048991112565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/4386783048991112565'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2017/11/javasqlsqlexceptioninvalid-state.html' title='java.SQl.Sqlexception:Invalid state, the connection object is closed'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-2074017465330095568</id><published>2015-01-23T23:20:00.001+05:30</published><updated>2015-07-01T22:55:43.016+05:30</updated><title type='text'>Use Polymorphism and code to Interface instead of if and elseif</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
if elseif else comes under procedural programming, When we talk about Object Oriented programming we need to escape out from if elseif else&amp;nbsp; until any primitive data type is using for.Means In Object Oriented programming if elseif else is used only for primitive data type not for objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let talk about some simple example with if else and try to convert this if else to purely object oriented.&lt;br /&gt;
&lt;br /&gt;
suppose you have two user say &quot;GUEST&quot; and &quot;ADMIN&quot;, w.r.t to this userType&amp;nbsp; you have to write&amp;nbsp; some bussiness logic.Since i am java developer and i need to think about Object oriented programming not&amp;nbsp; procedural programming .&lt;br /&gt;
&lt;br /&gt;
Firt&#39;s let go with&amp;nbsp; most familiar flow which basically maximum java developer follow to do task and what&#39;s that&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;String userType=&quot;&quot;//it can be either Guest or Admin&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;if(&quot;guest&quot;.equalsIgnoreCase(userType)){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;doGuestBussinessLogic();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;else if(&quot;admin&quot;.equalsIgnoreCase(userType)){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;doAdminBussinessLogic();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}else{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;throwExceptionOrDoNothing();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In don&#39;t know&amp;nbsp; about other but i definitely say that we are writing C-program in java Syntax&lt;br /&gt;
&lt;br /&gt;
Now Lets try this in Pure java language&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;public interface User {&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void bussinessLogicofUser();&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;public class AdminUser implements User {&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void bussinessLogicofUser() {&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Admin user bussiness logic started&quot;);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;public class GuestUser implements User {&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void bussinessLogicofUser(){&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Guest user bussiness logic started&quot;);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;public enum UserType {&lt;br /&gt;ADMIN(new AdminUser()),GUEST(new GuestUser());&lt;br /&gt;User user;&lt;br /&gt;&lt;br /&gt;private UserType(User user) {&lt;br /&gt;&amp;nbsp; this.user = user;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;public User &lt;/b&gt;&lt;b&gt;&lt;b&gt;getUserTypeInstance&lt;/b&gt;(){&lt;br /&gt;&amp;nbsp; return this.user;&lt;br /&gt;}&lt;br /&gt;}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now in Main method where we write if else,it&#39;s time to delete that if else and write object oriented program.Let see how&lt;br /&gt;
try{&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;UserType.valueOf(userType.toUpperCase()).getUserTypeInstance().bussinessLogicofUser();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;}&lt;b&gt;catch(IllegalArgumentException e){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;b&gt;throwExceptionOrDoNothing();&lt;/b&gt; &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Early we have written approx 7 line of code and here only 1 line code did that work.&lt;br /&gt;
That&#39;s the using of Object Oriented Program&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/2074017465330095568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/2074017465330095568' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/2074017465330095568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/2074017465330095568'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2015/01/dont-use-if-elseif-else-for-object.html' title='Use Polymorphism and code to Interface instead of if and elseif'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-2842679228448726202</id><published>2013-01-08T18:05:00.002+05:30</published><updated>2013-01-08T18:12:42.626+05:30</updated><title type='text'>How to configure Apache solr in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;When we talk about search engine application then solr came in many of us mind.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;In many tutorial we find that to use Apache solr we need to configure it inside server like tomcat but what if your tomcat get corrupted &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;at that time your solr project come in critical suitation.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Today i explain my personal experience of configuring about solr in project itself.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Fist step you need to download latest version of solr &lt;a href=&quot;http://lucene.apache.org/solr/downloads.html&quot; target=&quot;_blank&quot;&gt;click here&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;NOw extract the download file and move to the following path &quot;apache-solr-latest-version/example/&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;there you find &quot;solr&quot; folder copy that folder and paste it in home directory.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #20124d; font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #351c75; font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Now again move to following folder&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&quot;apache-solr-latest-version/example/webapps&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #351c75; font-size: large;&quot;&gt;extract the solr.war and then move&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;solr/WEB-INF/lib&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;now copy all jar file this jar file you need to add in your project lib folder&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Now create Tomcat project/Dynamice web project as normally you do.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br style=&quot;color: #351c75;&quot; /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #351c75; font-size: large;&quot;&gt;open web.xml file and add the following code&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp; &amp;lt;env-entry&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;env-entry-name&amp;gt;solr/home&amp;lt;/env-entry-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;env-entry-value&amp;gt;${user.home}/solr&amp;lt;/env-entry-value&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;env-entry-type&amp;gt;java.lang.String&amp;lt;/env-entry-type&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/env-entry&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;here we setting the path of solrconfig.xml files which is now inside ur home directory/solr/config we need to specify the path upto solr folder&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt; &amp;lt;filter&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;filter-name&amp;gt;SolrRequestFilter&amp;lt;/filter-name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;filter-class&amp;gt;org.apache.solr.servlet.SolrDispatchFilter&amp;lt;/filter-class&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-size: large;&quot;&gt;&amp;nbsp; &amp;lt;/filter&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #351c75; font-size: large;&quot;&gt;this is the main class which is use to initiate the solr configuration&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Your confrigutaion is completed :)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;now user home folder/solr/conf you get solrconfig.xml,schema.xml arranged it as per your requirement and start the server&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;If you really enjoyed this &lt;br /&gt;give feedback&lt;br /&gt;thanks...... :)&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/2842679228448726202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/2842679228448726202' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/2842679228448726202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/2842679228448726202'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2013/01/how-to-configure-apache-solr-in-java.html' title='How to configure Apache solr in Java'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-2483484398660957005</id><published>2012-09-05T17:35:00.006+05:30</published><updated>2012-09-07T17:33:16.003+05:30</updated><title type='text'>where Protocol of serialization is defined in java..??</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Many of you used Serializable interface but have you ever think where the protocol of saving Serialization object is defned?&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Today i share my knowledge about it how much i know&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;first lest go through the process of saving object.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;class saveObject implements Serializable&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;public static void main(String args[])&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; saveObject sb=new saveObject();&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileOutputStream fo=new FileOutputStream(fileName);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ObjectOutputStream obs=new ObjectOutputStream(fo);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obs.writeObject(sb);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;now if saveObject class implements Serializable then only it work else it throw exception saveObject is not Serialized&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;this protocol is define in inside ObjectOutputStream.writeObject(Object) method&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;lets check the method what it have&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;public final void writeObject(Object obj) throws IOException {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (enableOverride) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeObjectOverride(obj);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeObject0(obj, false);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (IOException ex) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (depth == 0) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeFatalException(ex);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; throw ex;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;here enableOverride is boolean type whose value get assign false inside ObjectOutputStream(fo) constructor&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;so&amp;nbsp; writeObject0(obj, false); get execute &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;now lets see what in&amp;nbsp; writeObject0(obj, false) method&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void writeObject0(Object obj, boolean unshared) &lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; throws IOException &lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; boolean oldMode = bout.setBlockDataMode(false);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; depth++;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // handle previously written and non-replaceable objects&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int h;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if ((obj = subs.lookup(obj)) == null) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeNull();&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (!unshared &amp;amp;&amp;amp; (h = handles.lookup(obj)) != -1) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeHandle(h);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (obj instanceof Class) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeClass((Class) obj, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (obj instanceof ObjectStreamClass) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeClassDesc((ObjectStreamClass) obj, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // check for replacement object&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Object orig = obj;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Class cl = obj.getClass();&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ObjectStreamClass desc;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for (;;) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // REMIND: skip this check for strings/arrays?&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Class repCl;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; desc = ObjectStreamClass.lookup(cl, true);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (!desc.hasWriteReplaceMethod() ||&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (obj = desc.invokeWriteReplace(obj)) == null ||&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (repCl = obj.getClass()) == cl)&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cl = repCl;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (enableReplace) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Object rep = replaceObject(obj);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (rep != obj &amp;amp;&amp;amp; rep != null) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cl = rep.getClass();&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; desc = ObjectStreamClass.lookup(cl, true);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; obj = rep;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // if object replaced, run through original checks a second time&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (obj != orig) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; subs.assign(orig, obj);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (obj == null) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeNull();&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (!unshared &amp;amp;&amp;amp; (h = handles.lookup(obj)) != -1) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeHandle(h);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (obj instanceof Class) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeClass((Class) obj, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (obj instanceof ObjectStreamClass) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeClassDesc((ObjectStreamClass) obj, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // remaining cases&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (obj instanceof String) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeString((String) obj, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (cl.isArray()) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeArray(obj, desc, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (obj instanceof Enum) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeEnum((Enum) obj, desc, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else if (obj instanceof Serializable) {&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #274e13;&quot;&gt;//check this line&lt;/span&gt;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; writeOrdinaryObject(obj, desc, unshared);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; throw new NotSerializableException(cl.getName());&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; depth--;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; bout.setBlockDataMode(oldMode);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;as per different condition it perform the action i will not go in detail .Just go through the code where i comment check this line&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;here our condition get satisfied only if our class implements Serializable interface else it throw exception NotSerializableException&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;if obj not belong to Enum,String ,Class,ObjectStreamClass.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;writeOrdinaryObject(obj, desc, unshared); do the rest thing of saving object&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;For reading object near about&amp;nbsp; same concept happened in &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;ObjectInputStream obi=new ObjectInputStream(new FileOutputStream(fileName));&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;obi.readObject()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/2483484398660957005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/2483484398660957005' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/2483484398660957005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/2483484398660957005'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2012/09/where-protocol-of-serialization-is.html' title='where Protocol of serialization is defined in java..??'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-5831649423886701045</id><published>2012-08-16T18:11:00.000+05:30</published><updated>2012-09-07T17:51:23.330+05:30</updated><title type='text'>Cause of Error and Exception occur at Runtime in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;1)java.lang.UnsupportedClassVersionError&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;This exception occur when you compile the java class with higher version of java environment and try to run that class file in lower version of java environment&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;for example if you compile the java class with java6 and try to&amp;nbsp; run that class with java5 you faced this type of exception&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;2)java.lang.NoClassDefFoundError&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;This exception occurs when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;possibility of this:&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;a) Class is not available in Java Classpath.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;b) You might be running your program using jar command and class was not defined in manifest file&#39;s ClassPath attribute.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;c) Any start-up script is overriding Classpath environment variable.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;d) Because NoClassDefFoundError is a sub class of java.lang.LinkageError it can also come if one of it dependency like native library may not available.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;e) Check for java.lang.ExceptionInInitializerError in your log file. NoClassDefFoundError due to failure of static initialization is quite common.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;f) If you are working in J2EE environment than visibility of Class among multiple Classloaders can also cause java.lang.NoClassDefFoundError, see examples and scenario section for detailed discussion.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;3)java.lang.ClassNotFoundException&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;This exception is nor similair with java.lang.NoClassDefFoundError because ClassNotFoundException comes when JVM tries to load a class at runtime dynamically means you give the name of class at runtime and then JVM tries to load it and if that class is not found in classpath it throws&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;java.lang.ClassNotFoundException. While in case of NoClassDefFoundError the problematic class was present during Compile time and that&#39;s why program was successfully compile but not available during runtime by any reason.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;4)java.lang.ClassCastException&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;This exception occur when we attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #660000;&quot;&gt;Object x = new Integer(0);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println((String)x);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;5)java.lang.ArrayIndexOutOfBoundsException&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;This exception occur when we accessed the array with an illegal index. The index is either negative or greater than or equal to the size of the array. &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;we always have to remember that The array indexes in Java start from 0 and go to array.length - 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;6)java.lang.NullPointerException&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;This exception is most common and every developer faced this exception once in there life.This exception occur when you performed any operation for null object.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;To avoid this kind of exception check the null condition before performing any operation of object&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;for example &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;String s=null;//here s&amp;nbsp; is null at present and now if we preform&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;s.toString();//here you faced NullPointerException&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;always check null like&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;if(s!=null)&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;s.toString();&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;If you really enjoyed this &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;give feedback&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;thanks...... :)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/5831649423886701045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/5831649423886701045' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/5831649423886701045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/5831649423886701045'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2012/08/cause-of-error-and-exception-occur-at.html' title='Cause of Error and Exception occur at Runtime in Java'/><author><name>Abhishek Mishra</name><uri>http://www.blogger.com/profile/04808227201838414532</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-3471915417101900072</id><published>2012-06-07T10:07:00.001+05:30</published><updated>2012-06-08T17:45:51.613+05:30</updated><title type='text'>Jvm  not only  read Bytecode created by compiler and run it,apart from it, it do a lot work for us</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;while running this program i get stuck.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;class A{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;A&quot;);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String ar[]){&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;A&#39;s main &quot;);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;class B extends A{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;B&quot;);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;public class C {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static{&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;C&quot;);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) {&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; B.main(null);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #274e13;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Now lest run the class C and see what the o/p is:&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;C&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;A&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;A&#39;s main&lt;/span&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;As per java concept whenever class loaded in memory its static block get executed.its fine.....&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;now just move step by step for above program.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;first class C is loaded in memory so class C static block execute first, then main() method get executed&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;now let see what inside main method of class C?&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;B.main(null)&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;ok&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;now what class B have?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;have one static block only inside and extending class A..ok&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;now what class A have?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;have a main method and one static block.here everything is fine&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;through class B we reaching to class A&#39;s main method because class B extending class A fine....&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;but when i check the output i have seen class B static block is not get executed means class B is not loaded to memory but without loading class B how class A get loaded..???? &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;i discuss with many people, some say compiler do some edition when we compile the class.but what compler do..???&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;compiler never have a right to delete our single character then how class B get erased/override and if B is not erase/override then why class B is not loaded on the line executing&quot;B.main(null)&quot;&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;so by saying that compiler take care of this is absolutely wrong because compiler ony make our word meaningfull like for String it make java.lang.String and perform some complusray task if we not did like extending Object class and creating default constructor if we not create&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Then i study JVM ,to know what actual JVM do&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;and&amp;nbsp; finally get the answer for this issue&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Class are made available to a running program by the Java Virtual Machine. This is done through a process of loading, linking, and initialization. Loading is the process of locating the binary representation of a type and bringing it into the JVM. Linking is the process of taking the type and incorporating it into the runtime state of the JVM so that it can be executed. Initialization is the process of executing the initializers of a type (static initializers for classes; static field initializers for classes and interfaces). When a type becomes unreachable (i.e. the running application has no references to the type), it becomes eligible for garbage collection. This collection is called type unloading.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Here are the step follow when we run our any java program:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp; 1. Given a class&#39;s fully qualified name, produce a stream of binary data that represents that type&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp; 2. Parse the stream of binary data produced in step #1 into internal structures in the method area of the JVM. The method area is a logical area of memory in the VM that is used to store information about loaded types.&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;&amp;nbsp;&amp;nbsp; 3. Create an instance of class java.lang.Class that represents the class indicated in step #1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;According to this lets explain tha above details&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;B.main(null) come under binary data as mention in step #1&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;while parsing the data JVM link main(null) directly to class A becuase Main method exist in class A and load only class A&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;because of that class B not get overloaded&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;If you really enjoyed this &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;give feedback&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;thanks...... :)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/3471915417101900072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/3471915417101900072' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/3471915417101900072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/3471915417101900072'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2012/06/jvm-not-only-to-read-bytecode-created.html' title='Jvm  not only  read Bytecode created by compiler and run it,apart from it, it do a lot work for us'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-7291538523865155375</id><published>2012-03-19T17:35:00.000+05:30</published><updated>2012-03-19T17:35:45.121+05:30</updated><title type='text'>Is downcasting is possible regarding object  in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;By the begining of Languages downcasting has a issue.lets checks with C-language&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;void main()&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;long i=98765431;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;byte j=(byte) i;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;printf(j);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;here data overflow and get unexcepted result.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Before discussing this topic first we go through the defination of  Upcasting and downcasting&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;What is upcasting?&lt;/span&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;UpCasting is defined as casting a reference of a parent class type to a type of a  reference to a child class.&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;What is downcasting?&lt;/span&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Downcasting is defined as casting a reference of a child class type to a type of a  reference to a parent class.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Upcasting can de done automatically means implicity in java and&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Downcasting we have to do explicity else we get compile time error&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;now lets going  through the defination of upcasting and downcasting code the java program and check....&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;class parent&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;class child extend parent&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;public static void main(String args[])&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;line 1:&lt;/span&gt; parent p=new child();  //upcasting happened complile and run successfully&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;line 2:&lt;/span&gt; child c=new parent();  // downcasting but not explicity so we get compile time error&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;line 3:&lt;/span&gt; child c1=(child) new parent(); // downcasting explicity compile success but give run time error class cast exception &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;now just read  the downcasting defination above and check line 3 of above program,we are doing downcasting but it not happening here.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;many of us say downcasting is happened in java and gave the example mention below&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;class parent&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;class child&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;public static void main(String args[])&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;line 1:&lt;/span&gt; parent p=new child(); //upcasting&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;line 2:&lt;/span&gt; child c=(child) p; //downcasting,compile and run success&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #660000;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;look carefully at line 2 we really doin downcasting,i don&#39;t think downcasting is not suitable word here we are doing here typecasting&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;in simple we can say that:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;at line 1  we create object of child and say that you are parent type&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;and at line 2 we again saying to same child object that you are child type here where is the parent object that we are casting to child type..????&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;what is my opion on this issue is there i posted on this blog....&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;still have little bit confusion and hoping someone to clear this confusion&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;If you really enjoyed this &lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;give feedback&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;thanks...... :)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/7291538523865155375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/7291538523865155375' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/7291538523865155375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/7291538523865155375'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2012/03/is-downcasting-is-possible-regarding.html' title='Is downcasting is possible regarding object  in Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-8901203917688020761</id><published>2011-12-24T10:04:00.000+05:30</published><updated>2012-02-16T17:47:56.801+05:30</updated><title type='text'>Secret in java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;First look at the code:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;Integer i=new Integer(5);&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;integer j=10;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;here what happening two object is created of integer type whose value type is int&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Integer value lies between -2147483648 to 2147483647&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;ok fine...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;Integer i=127;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt; Integer j=127;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;here what happen one object is created pointed by two referece i and j&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;lets see..&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;if(i==j)&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;{System.out.println(&quot;yes&quot;);}&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #660000;&quot;&gt;{System.out.println(&quot;no&quot;);}&lt;/span&gt;&lt;br style=&quot;color: #274e13;&quot; /&gt;&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;here o/p we get &lt;span style=&quot;color: #274e13;&quot;&gt;yes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Now once again.......&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;Integer a=128;&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;Integer b=128;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;here what happen two object is created one pointed by&amp;nbsp; referece a and another pointing by reference b&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;lets see..&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;if(a==b)&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;{System.out.println(&quot;yes&quot;);}&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;else{System.out.println(&quot;no&quot;);}&lt;/span&gt;&lt;br style=&quot;color: #274e13;&quot; /&gt;&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;here o/p we get &lt;span style=&quot;color: #274e13;&quot;&gt;no&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;How it happen...?????&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;Initially I too get shocked ,&lt;span style=&quot;color: #274e13;&quot;&gt; how it happen?&lt;/span&gt;,i opened the book, surf the site then i came to the conclusion....&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;Bydefault jvm have limited heap memory which we can increase manually......&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;because of this bydefault limited heap memory Integers between -127 and 127 are &#39;cached&#39; in such a way&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;that when you use those numbers you always refer to the same number in memory, which is why your == works.&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;In simple we can say that Integer value can be consider as three type&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #274e13;&quot;&gt;Data Type&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #274e13;&quot;&gt; Value&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;nbsp; Memory&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;byte&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -128 -- +127&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; occupy 1 byte (8 bits) in memory&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;short&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -32768 -- 32767&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; occupy 2 bytes (16 bits) in memory&lt;/span&gt;&lt;br style=&quot;color: #660000;&quot; /&gt;&lt;span style=&quot;color: #660000;&quot;&gt;int&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -2147483648 -- 2147483647&amp;nbsp;&amp;nbsp; occupy 4 bytes (32 bits) in memory&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;and for least data type i.e byte value is cached in such a way that when you use those numbers you always refer to the same number in memory,because of limit heap memory&lt;/span&gt;&lt;br style=&quot;color: #20124d;&quot; /&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;span style=&quot;color: #003300;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #993399;&quot;&gt;If you really enjoyed this &lt;br /&gt;
give feedback&lt;br /&gt;
thanks...... :)&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/8901203917688020761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/8901203917688020761' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/8901203917688020761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/8901203917688020761'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2011/12/secret-in-java.html' title='Secret in java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4555712962561805550.post-3680960667850360684</id><published>2011-12-06T09:43:00.000+05:30</published><updated>2012-02-16T17:57:49.882+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="20124d"/><title type='text'>Check at what techniques your OS is working through Java.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #20124d; font-size: 130%;&quot;&gt;There are two major types of  scheduling techniques in the modern operating systems: &lt;span style=&quot;color: #38761d;&quot;&gt;round-robin&lt;/span&gt; and  &lt;span style=&quot;color: #38761d;&quot;&gt;time-slicing&lt;/span&gt;.Now how can you identify at what techniques your OS is  working through Java.&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;class Thready {&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  public static void main( String args [] ) {&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;      new MyThread(&quot;A&quot;).start();&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;      new MyThread(&quot;B&quot;).start();&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;class MyThread extends Thread {&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  String message;&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  MyThread ( String message ) {&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;      this.message = message;&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  public void run() {&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;      while ( true )&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;          System.out.print( message );&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-size: 130%;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #20124d; font-size: 130%;&quot;&gt;if you get O/P:&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #009900; font-size: 130%;&quot;&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBB&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;then  your OS is using Round Robin,The  output is generated by an  implementation of Java virtual machine for a preemptive system like UNIX  OSF1, Windows 95, Windows NT, etc,&lt;br /&gt;
&lt;br /&gt;
if your O/P is:&lt;br /&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...........&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #20124d;&quot;&gt;then  it using time-slicing ,the output is generated by an implementation of  Java virtual machine for a non-preemptive system based on Solaris UNIX  platforms&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&lt;span style=&quot;color: #003300;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #993399;&quot;&gt;If you really enjoyed this &lt;br /&gt;
give feedback&lt;br /&gt;
thanks...... :) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #009900; font-size: 130%;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #20124d;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://abhi4tech.blogspot.com/feeds/3680960667850360684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4555712962561805550/3680960667850360684' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/3680960667850360684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4555712962561805550/posts/default/3680960667850360684'/><link rel='alternate' type='text/html' href='http://abhi4tech.blogspot.com/2011/12/ckeck-at-what-techniques-your-os-is.html' title='Check at what techniques your OS is working through Java.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry></feed>