title: Error Stating "Bad version in .class file"
body: <p>I worked with a JSP code and executed the same under the tomcat5.5 server. It worked fined. Now I have copied the same code to the other system under tomcat server. But while submission of that jsp file, am receiving the following error. What might be the cause for the error? Please advise.</p>
  
  <pre><code>root cause:
  javax.servlet.ServletException: Bad version number in .class file (unable to load class myfirst.SearchLink)
  org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
  org.apache.jsp.Test_jsp._jspService(Test_jsp.java:70)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  
  java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class myfirst.SearchLink)
  org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1962)
  org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:931)
  org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1403)
  org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1282)
  org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:125)
  org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
  java.lang.ClassLoader.loadClassInternal(Unknown Source)
  org.apache.jsp.Test_jsp._jspService(Test_jsp.java:51)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Even after compiling all the java code I have, in the current version of java, I get the same error..</p>
  
  <p><strong>RECENT UPDATE</strong></p>
  
  <p>@Pangea Yes am using myfirst.SearchLink in my JSP code as follows,</p>
  
  <p><code>myfirst.SearchLink o=new myfirst.SearchLink();
          String result=o.checkURL(url);</code></p>
  
  <p>And my java code for SearchLink is as below,</p>
  
  <pre><code>package myfirst;
  
  import java.net.URL;
  import java.net.URLConnection;
  import java.sql.*;
  public class SearchLink{
  public static void main(String args[]) throws Exception {
  
  
  }
  
  public String checkURL(String link)throws SQLException{
      Connection con=null;
      Statement stmt=null;
      Statement stmtR=null;
      String mem;
      if(con==null){
              SQLConnection.setURL("jdbc:sqlserver://192.168.2.53\\SQL2005;user=sa;password=365media;DatabaseName=LN_ADWEEK");
              con=SQLConnection.getNewConnection();
              stmt=con.createStatement();
              stmtR=con.createStatement();
      }
      try{
          ResultSet rs;
          boolean hasRows=false;
          rs=stmt.executeQuery("select url from urls_linkins where url='"+link+"'");
          while(rs.next()){
              hasRows=true;
              //String mem=rs.getString(1);
              rs.close();
              return "This URL already exists in DB";
          }
          rs.close();
          if (!hasRows)
          {
              URL url = new URL(link);
              String domain=url.getHost();
              String Str="This URL does not exist in DB&lt;br&gt;&lt;br&gt;&lt;br&gt;";
              rs=stmtR.executeQuery("select url from urls_linkins where url like '%"+domain+"%'");
              boolean flag=false;
              while(rs.next()){
                  if(!flag){
                  Str=Str+"&lt;Br&gt;"+"Similar Domains in DB are";
                  }
                  flag=true;
                  mem=rs.getString(1);
                  //System.out.println("Similar Domains already in DB"+mem);
                  Str=Str+"&lt;Br&gt;"+mem;
              }
              return Str;
          }
          return "This URL does not exist in DB";
      }catch(Exception e){
          e.printStackTrace();
          return e.getMessage();
      }finally{
          if(stmtR!=null){
              stmtR.close();
          }
          if(stmt!=null){
              stmt.close();
          }
          if(con!= null){
              con.close();
          }
  
      }
  }
  
  
  public String addURL(String link,String source)throws SQLException{
          Connection con=null;
          Statement stmt=null;
          Statement stmtR=null;
          final String rssvar="Rss";
          if(con==null){
                  SQLConnection.setURL("jdbc:sqlserver://192.168.2.53\\SQL2005;user=sa;password=365media;DatabaseName=LN_ADWEEK");
                  con=SQLConnection.getNewConnection();
                  stmt=con.createStatement();
                  stmtR=con.createStatement();
      }
          try{
              PreparedStatement insertUrlStatement = con.prepareStatement("INSERT INTO urls_linkins(url, source_name, is_active, is_periodic, Link_Type, New_Entry) VALUES(?, ?, ?, ?, ?, ?)");
              //insertUrlStatement.setInt(1, 21211);
              insertUrlStatement.setString(1, link);
              insertUrlStatement.setString(2, source);
              insertUrlStatement.setInt(3, 1);
              insertUrlStatement.setInt(4, 0);
              insertUrlStatement.setString(5, rssvar);
              insertUrlStatement.setInt(6, 1);
              insertUrlStatement.executeUpdate();
              insertUrlStatement.close();
              return "The URL has been added to the Database";}
          catch(Exception e){
              e.printStackTrace();
              return e.getMessage();
          }finally{
              if(stmtR!=null){
                  stmtR.close();
              }
              if(stmt!=null){
                  stmt.close();
              }
              if(con!= null){
                  con.close();
              }
          }
  
  
  }
  
  public String addURL1(String link,String source)throws SQLException{
          Connection con=null;
          Statement stmt=null;
          Statement stmtR=null;
          final String other="Other";
          if(con==null){
                  SQLConnection.setURL("jdbc:sqlserver://192.168.2.53\\SQL2005;user=sa;password=365media;DatabaseName=LN_ADWEEK");
                  con=SQLConnection.getNewConnection();
                  stmt=con.createStatement();
                  stmtR=con.createStatement();
      }
          try{
              PreparedStatement insertUrlStatement = con.prepareStatement("INSERT INTO urls_linkins(url, source_name, is_active, is_periodic, Link_Type, New_Entry) VALUES(?, ?, ?, ?, ?, ?)");
              //insertUrlStatement.setInt(1, 21211);
              insertUrlStatement.setString(1, link);
              insertUrlStatement.setString(2, source);
              insertUrlStatement.setInt(3, 1);
              insertUrlStatement.setInt(4, 0);
              insertUrlStatement.setString(5, other);
              insertUrlStatement.setInt(6, 1);
              insertUrlStatement.executeUpdate();
              insertUrlStatement.close();
              return "The URL has been added to the Database";}
          catch(Exception e){
              e.printStackTrace();
              return e.getMessage();
          }finally{
              if(stmtR!=null){
                  stmtR.close();
              }
              if(stmt!=null){
                  stmt.close();
              }
              if(con!= null){
                  con.close();
              }
          }
  }
  
  public String addmultiple(String file)throws SQLException{
          return file;
  }
  }
  </code></pre>