Prash's Blog

Get Java Timezone list September 8, 2012

Filed under: Java — prazjain @ 7:48 pm
Tags: ,

If you have had same problem as me and you needed to know the java timezone id / name for a particular city / country and could not figure that out.
Here is a code snippet that can help you do that.

import java.util.*;

public class TestZones
{
	public static void main(String[] args)
	{
		for (String string : TimeZone.getAvailableIDs(TimeZone.getTimeZone("GMT+08:00").getRawOffset())) 
		{
    			System.out.println(string);
		}
	}
}
 

java.lang.VerifyError: Expecting a stackmap frame at branch target January 19, 2012

Filed under: Google App Engine,Java — prazjain @ 6:30 pm
Tags: ,

If you get this same error :


WARNING: Error for /doit
java.lang.VerifyError: Expecting a stackmap frame at branch target 27 in method com.yourpackage.YourServlet.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V at offset 11
 at java.lang.Class.getDeclaredConstructors0(Native Method)
 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
 at java.lang.Class.getConstructor0(Class.java:2714)
 at java.lang.Class.newInstance0(Class.java:343)
 at java.lang.Class.newInstance(Class.java:325)
 at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
 at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
 at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
 at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

 

then you need to add an attribute -XX:UseSplitVerifier to your Default VM arguments.

On Eclipse : Windows -> Preferences -> Java -> Installed JRE’s

And selected and edit, the one that you are using, to include -XX:-UseSplitVerifier

Hope that helps

 

Search Engine in Java August 5, 2009

Filed under: Java — prazjain @ 3:45 pm
Tags: ,

In this post I would try to dissect the Search Engine I built in Java during my free time in College (that was 2005.. ah those were the days).

Do not worry if you are a first timer and do not know how search engines work,I would try to put in additional references to the articles that I found helpful when I was building mine (that was around 4 years back!) and I had zilch knowledge about how Search Engines really worked.

When I tried to take this up, I still had to worry about my daily classes, quizes, end terms and gradesĀ  :), so I tried to do the best I could do in the month and a half to build mine. In that time I had to research all I could about various aspects of a search engine, and also know what components I could develop on my own in the time constraints I had. So for few things I went for off-the-shelf libraries that were available.

This is how I started, and would recommend this as a mandatory study for knowing what components are there in a search engine and how they are glued together. While I was doing this, I never really had any interaction with anyone else about it or never really had any other resource to know what Search Engine is about, so if you are in the same boat then you do not have to worry. Just follow the link (and go through it as many times as needed until you feel comfortable) :

http://infolab.stanford.edu/~backrub/google.html

I am a believer in Head Fake learning. Through project like this and a few others I got way better at concepts like multi-threading and caching across multiple threads.

I would start digging out the source code from wherever I stored it, and then write out a multi-series article explaining it. This whole series could take a while to complete.

Update after 6 months of writing this post : Search engines are no longer the hot thing anymore and there are quite of few of them available in open source now, so I would save myself some effort here and close this topic by saying that unless someone here wants to know it, I would not be publishing it on my blog.

Cheers