How to fix 'class' or 'interface' expected for jsp

below is the stack trace
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
/home/sherali/.netbeans/5.5/apache-tomcat-5.5.17_base/work/Catalina/localhost/UVSDataSearch/org/apache/jsp/pager_002ddemo_jsp.java:7: 'class' or 'interface' expected
import java.util.*;
^
Generated servlet error:
/home/sherali/.netbeans/5.5/apache-tomcat-5.5.17_base/work/Catalina/localhost/UVSDataSearch/org/apache/jsp/pager_002ddemo_jsp.java:8: 'class' or 'interface' expected
import java.io.*;
^
2 errors
thanks a lot in advance.
my jsp is
<%@ page session="false" %>
<%@ page import="tauvex.*;" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<html>
<head>
<title>Tauvex Search Results</title>
<%
* Pager Tag Library
* Copyright (C) 2002 James Klicman <[email protected]>
* The latest release of this tag library can be found at
* http://jsptags.com/tags/navigation/pager/
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
%>
<style type="text/css">
A.nodec { text-decoration: none; }
</style>
</head>
<body bgcolor="#ffffff">
<%
String style = getParam(request, "style", "simple");
String position = getParam(request, "position", "top");
String index = getParam(request, "index", "center");
int maxPageItems = getParam(request, "maxPageItems", 3);
int maxIndexPages = getParam(request, "maxIndexPages", 3);
%>
<%
String query1=(String)request.getAttribute("query1");
String query=(String)request.getAttribute("query");
String ShowFile=(String)request.getAttribute("ShowFile");
String ShowRA=(String)request.getAttribute("ShowRA");
String ShowDEC=(String)request.getAttribute("ShowDEC");
String Telescope=(String)request.getAttribute("Telescope");
String ObservationDates=(String)request.getAttribute("ObservationDates");
String Filter=(String)request.getAttribute("Filter");
String RA=(String)request.getAttribute("RA");
String DEC=(String)request.getAttribute("DEC");
String DATE=(String)request.getAttribute("DATE");
String DATE1=(String)request.getAttribute("DATE1");
String Radious=(String)request.getAttribute("Radious");
String FILTER[]=(String[])request.getAttribute("FILTER");
String OrderBy1=(String)request.getAttribute("OrderBy1");
String OrderBy2=(String)request.getAttribute("OrderBy2");
String OrderBy3=(String)request.getAttribute("OrderBy3");
%>
<%
out.println("<form action=\"PlainSQLQuery\" method=POST>");
out.println("<textarea rows = 5 cols = 40 name=query id=\"query\">");
out.println(query);
out.println("</textarea>");
out.println("<input type = submit value = \"Submit\">");
out.println("<input type = reset value = \"Reset\">");
out.println("</form>");
%>
<center>
<table border="0" width="90%" cellpadding="4">
<tr>
<td colspan="2" align="left" valign="top">
<table border="0" cellspacing="2" cellpadding="0">
<tr><td>Max. Page Items </td>
<td><input type="text" size="4" name="maxPageItems" value="<%= maxPageItems %>" onChange="this.form.submit();"></td></tr>
<tr><td>Max. Index Pages </td>
<td><input type="text" size="4" name="maxIndexPages" value="<%= maxIndexPages %>" onChange="this.form.submit();"></td></tr>
</table>
</td>
</tr>
</table>
<pg:pager
index="<%= index %>"
maxPageItems="<%= maxPageItems %>"
maxIndexPages="<%= maxIndexPages %>"
url="TauvexDataServlet"
export="offset,currentPageNumber=pageNumber"
scope="request">
<%-- keep track of preference --%>
<pg:param name="style"/>
<pg:param name="position"/>
<pg:param name="index"/>
<pg:param name="maxPageItems"/>
<pg:param name="maxIndexPages"/>
<pg:param name="RA"/>
<pg:param name="DEC"/>
<pg:param name="DATE"/>
<pg:param name="DATE1"/>
<pg:param name="Radious"/>
<pg:param name="FILTER"/>
<pg:param name="ShowRA"/>
<pg:param name="ShowDEC"/>
<pg:param name="Telescope"/>
<pg:param name="ObservationDates"/>
<pg:param name="Filter"/>
<pg:param name="OrderBy1"/>
<pg:param name="OrderBy2"/>
<pg:param name="OrderBy3"/>
<%-- save pager offset during form changes --%>
<input type="hidden" name="pager.offset" value="<%= offset %>">
<%-- warn if offset is not a multiple of maxPageItems --%>
<% if (offset.intValue() % maxPageItems != 0 &&
("alltheweb".equals(style) || "lycos".equals(style)) )
%>
<p>Warning: The current page offset is not a multiple of Max. Page Items.
<br>Please
<pg:first><a href="<%= pageUrl %>">return to the first page</a></pg:first>
if any displayed range numbers appear incorrect.</p>
<% } %>
<%-- the pg:pager items attribute must be set to the total number of
items for index before items to work properly --%>
<% if ("top".equals(position) || "both".equals(position)) { %>
<br>
<pg:index>
<% if ("texticon".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/texticon.jsp" flush="true"/>
<% } else if ("jsptags".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/jsptags.jsp" flush="true"/>
<% } else if ("google".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
<% } else if ("altavista".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/altavista.jsp" flush="true"/>
<% } else if ("lycos".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/lycos.jsp" flush="true"/>
<% } else if ("yahoo".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/yahoo.jsp" flush="true"/>
<% } else if ("alltheweb".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/alltheweb.jsp" flush="true"/>
<% } else { %>
<jsp:include page="/WEB-INF/jsp/simple.jsp" flush="true"/>
<% } %>
</pg:index>
<% } %>
<hr>
<form action="ZipServlet" method="get" name="download" onsubmit="return Form1_Validator(this)">
<table id="output">
<CAPTION><EM>Fits file Search Results</EM></CAPTION><tr>
<%
out.println("<th>Check Box</th>");
out.println("<th>File Name</th>");
if(ShowRA != null && "on".equals(ShowRA))
out.println("<th>RA_START</th>");
if(ShowRA != null && "on".equals(ShowRA))
out.println("<th>RA_END</th>");
if(ShowDEC != null && "on".equals(ShowDEC))
out.println("<th>DEC_START</th>");
if(ShowDEC != null && "on".equals(ShowDEC))
out.println("<th>DEC_END</th>");
if(Telescope!=null && "on".equals(Telescope))
out.println("<th>Telescope</th>");
if(ObservationDates !=null && "on".equals(ObservationDates))
out.println("<th>STARTOBS</th>");
if(ObservationDates !=null && "on".equals(ObservationDates))
out.println("<th>ENDOBS</th>");
if(Filter!=null && "on".equals(Filter))
out.println("<th>FILTER</th>");
out.println("</tr>");
%>
<%--
<table width="90%" cellspacing="4" cellpadding="4">
Since the data source is static, it's easy to offset and limit the
loop for efficiency. If the data set size is not known or cannot
be easily offset, the pager tag library can count the items and display
the correct subset for you.
The following is an example using an enumeration data source of
unknown size. The pg:pager items and isOffset attributes must
not be set for this example:
--%>
<%
Enumeration myDataList1 = (Enumeration)request.getAttribute("myDataList1");
if (myDataList1 == null)
throw new RuntimeException("myDataList1 is null");
%>
<% while (myDataList1.hasMoreElements()) { %>
<% TauvexData elem = (TauvexData)myDataList1.nextElement(); %>
<pg:item> <%
out.println("<tr>");
%>
<td><input type= "checkbox" name="cb" value="<%=elem.getDownload()%>"></td>
<td><a href="<%= elem.getDownload() %>"><%= elem.Fitsfilename %></a></td>
<%
// out.println("<td> "+elem.Fitsfilename+" </td>");
if(ShowRA != null && "on".equals(ShowRA))
out.println("<td> "+elem.RA_START+" </td>");
if(ShowRA != null && "on".equals(ShowRA))
out.println("<td> "+elem.RA_END+"</td>");
if(ShowDEC != null && "on".equals(ShowDEC))
out.println("<td> "+elem.DEC_START+" </td>");
if(ShowDEC != null && "on".equals(ShowDEC))
out.println("<td> "+elem.DEC_END+" </td>");
if(Telescope!=null && "on".equals(Telescope))
out.println("<td> "+elem.telescope+" </td>");
if(ObservationDates !=null && "on".equals(ObservationDates))
out.println("<td> "+elem.STARTOBS+" </td>");
if(ObservationDates !=null && "on".equals(ObservationDates))
out.println(" <td> "+elem.ENDOBS+" </td>");
if(Filter!=null && "on".equals(Filter))
out.println("<td> "+elem.FILTER+" </td>");
out.println("</tr>");
%> </pg:item>
<% } %>
</table>
<input type="button" name="CheckAll" value="Check All Boxes" onclick="modify_boxes(true,3)">
<input type="button" name="UnCheckAll" value="UnCheck All Boxes" onclick="modify_boxes(false,3)">
<input type="submit" value="Download">
</form>
<hr>
<pg:pages>
<a href="<%= pageUrl %>"><%= pageNumber %></a>
</pg:pages>
<pg:last>
<a href="<%= pageUrl %>">[ Last >| (<%= pageNumber %>) ]</a>
</pg:last>
<% if ("bottom".equals(position) || "both".equals(position)) { %>
<pg:index>
<% if ("texticon".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/texticon.jsp" flush="true"/>
<% } else if ("jsptags".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/jsptags.jsp" flush="true"/>
<% } else if ("google".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/google.jsp" flush="true"/>
<% } else if ("altavista".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/altavista.jsp" flush="true"/>
<% } else if ("lycos".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/lycos.jsp" flush="true"/>
<% } else if ("yahoo".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/yahoo.jsp" flush="true"/>
<% } else if ("alltheweb".equals(style)) { %>
<jsp:include page="/WEB-INF/jsp/alltheweb.jsp" flush="true"/>
<% } else { %>
<jsp:include page="/WEB-INF/jsp/simple.jsp" flush="true"/>
<% } %>
</pg:index>
<% } %>
</pg:pager>
</center>
</body>
</html>
<%!
private static int num =1;
private static String getName(){
String str="cb";
str=str+num;
num++;
return str ;
private static final String getParam(ServletRequest request, String name,
String defval)
String param = request.getParameter(name);
return (param != null ? param : defval);
private static final int getParam(ServletRequest request, String name,
int defval)
String param = request.getParameter(name);
int value = defval;
if (param != null) {
try { value = Integer.parseInt(param); }
catch (NumberFormatException ignore) { }
return value;
private static void radio(PageContext pc, String name, String value,
boolean isDefault) throws java.io.IOException
JspWriter out = pc.getOut();
String param = pc.getRequest().getParameter(name);
out.write("<input type=\"radio\" name=\"");
out.write(name);
out.write("\" value=\"");
out.write(value);
out.write("\" onChange=\"this.form.submit();\"");
if (value.equals(param) || (isDefault && param == null))
out.write(" checked");
out.write('>');
%>

Well, putting all that Java code into a JSP was a bad idea in the first place, just on general design principles. But you've done it in such a way that the result of compiling the JSP is malformed Java code. Frankly I would just throw it away and put the Java code into a servlet or some other Java class, where it belongs.
But if you're really working in a place where nobody has learned anything since 2003, and you're forced to support that old junk, then I would point out that the error occurs before the place which generates this line:
import java.util.*;You only need to look at two of the thousand lines of code you posted.

Similar Messages

  • Compilation Error: "class or interface expected" for simple EAR???

    Dear all,
    I have access to the customers NW CE 7.1 SP07 and of course I am using the corresponding NWDS 7.1 SP07 that comes with this CE installation. I am trying to study JEE 5 @ SAP and I have created a very simple Application (from the Book http://www.sap-press.de/katalog/buecher/titel/gp/titelID-1480).
    In NWDS I have created the following 4 projects:
    1. Dictionary Project
    Describes 2 Tables (TMP_EMPLOYEES and TMP_ID_GEN)
    2. EJB 5 Project
    Contains a stateless EJB + local business interface + Entity class.
    The EJB accesses the entity class, which is mapped to a simple table (TMP_EMPLOYEES).
    3. Dynamic Web Project
    Contains actually only one JSP (index.jsp) which allows to the local business interface for creating a new Entity.
    4. Enterprise Application Project (EAR)
    Creates a package from 2. and 3.
    I have successfully deployed both the Dictionary Project and the EAR (all to the same server).
    But If I call the corresponding URL via web browser I get the following error:
    500   Internal Server Error
    "Error in compiling [/EmployeeWeb/index.jsp] in application [sap.com/EmployeeEar]."
    Details: "The WebApplicationException log ID is [005056841108002A00000070000007AC0139C8D8862D3EED]."
    In the "Log Viewer" of the "SAP NetWeaver Administrator" (via browser...) I have found the following:
    Message: Processing HTTP request to servlet [jsp] finished with error.
    The error is: com.sap.engine.services.servlets_jsp.server.jsp.exceptions.CompilingException: Error in executing the compilation process: [ Compilation Failed! Exit Code=1
    Command line executed: D:\usr\sap\CED\J00\exe\sapjvm_5\bin\\javac -source 1.5 -target 1.5 -encoding UTF-8 -d "D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work" -sourcepath "D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work\;" -classpath ".;D:\usr\sap\CED\J00\exe\jstartup.jar;D:\usr\sap\CED\J00\exe\sapjvm_5\lib\jvmx.jar;D:\usr\sap\CED\J00\exe\jre\lib\iqlib.jar;D:\usr\sap\CED\J00\exe\sapjvm_5\lib\tools.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\boot\sap.com~tc~bl~jkernel_boot~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\boot\jaas.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~bytecode~library.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\boot\memoryanalyzer.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\jperflib.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\jta.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~bytecode~library.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~cache_api~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~frame~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~gui~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~iqlib~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jdsr~jdsr.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_cache~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_classload~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_cluster~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_configuration~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_database~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_licensing~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_locking~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_log~api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_pool~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_service~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_thread~frame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~jkernel_util~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~bl~opensqlkernel~implOpenSQLFrame.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~exception~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~je~sessionmgmt~api_assembly.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~logging~java~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\sap.com~tc~logging~java~implPerf.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\system\vmc_storage_provider.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\timeout\sap.com~tc~je~timeout~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\servlet\servlet.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\cross_api\sap.com~tc~je~cross_api~API.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~antlr~runtime.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~bl~config~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~bl~cpt~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~bl~jarm~jarm.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~bl~opensqlkernel~implOpenSQL.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~bl~opensqlkernel~implOpenSQLPort.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~dd~db~dictionarydatabase~implDictionaryDatabase.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~je~bootstrap_core_lib~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\core_lib\sap.com~tc~sec~secstorefs~java~core.jar;D:\usr\sap\CED\J00\exe\mssjdbc\sqljdbc.jar;D:\usr\sap\CED\SYS\global\security\lib\engine\iaik_jce.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\log\sap.com~tc~je~log_api~API.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\mail.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\sap.com~tc~je~javamail_lib~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\activation.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\iaik_jsse.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\iaik_smime.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\iaik_ssl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\mail-activation-iaik\w3c_http.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.security.api.sda\sap.com~tc~sec~ume~api~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.security.api.sda\sap.com~tc~sec~ume~perm~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\security_api\sap.com~tc~je~security_api~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\shell\sap.com~tc~je~shell_api~API.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\cross\sap.com~tc~je~cross~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\visual_administration\sap.com~tc~bl~visual_administration~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\shell\sap.com~tc~je~shell~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\p4\sap.com~tc~je~p4~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sapxmltoolkit\sap.com~tc~sapxmltoolkit~sapxmltoolkit.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jts\jts.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~jmx\sap.com~tc~bl~pj_jmx~Impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~mmodel~lib\sap.com~tc~je~mmodel~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\appcontext_api\sap.com~tc~je~appcontext_api~API.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\naming\sap.com~tc~je~naming~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\j2eeca\connector.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\idl\idl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\resourceset_api\sap.com~tc~bl~resourceset~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\resourcecontext_api\sap.com~tc~bl~resourcecontext~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~txmanager~plb\sap.com~tc~bl~txmanagerimpl~plb~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\transactionext_api\sap.com~tc~bl~transactionext~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\ts\sap.com~tc~je~ts~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\csiv2_api\sap.com~tc~bl~csiv2~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\iiop\sap.com~tc~je~iiop~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\file\sap.com~tc~je~file~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.tc.Logging\sap.com~tc~logging~standard~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~bcanalysis\sap.com~tc~je~bcanalysis~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~reference_graph\lib\tc~bl~reference_graph_api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\container_api\sap.com~tc~je~container_api~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\webservices\sap.com~tc~je~webservices_api~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.util.monitor.jarm\sap.com~tc~bl~jarmsat~jarmsat.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~i18n~verify~intf\sap.com~tc~i18n~verify~intf~jar~IMPL.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~i18n~cp\sap.com~tc~i18n~cp~jar~IMPL.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~i18n~decfloat\sap.com~tc~i18n~decfloat~jar~IMPL.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~com.sap.conn.jco\sap.com~tc~bl~jco_sapj2ee~runtime.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.mw.jco\sap.com~tc~bl~jrfc~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\keystore_api\sap.com~tc~je~keystore_api~API.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\tc~sec~certrevoc~interface\sap.com~tc~sec~certrevoc~interface~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~https~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~compat~core.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~ssf~core.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~jaas~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~saml~toolkit~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~csi~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~util0~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~userstore~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~xmlbind~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\security.class\sap.com~tc~sec~destinations~lib~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.guid\sap.com~tc~bl~guidgenerator~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\stax_api\jsr173_1.0_api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\stax_api\sjsxp.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jaxb20\jaxb-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jaxb20\jaxb-xjc.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jaxb20\jaxb-impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\saaj13\saaj-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\saaj13\saaj-impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jaxws_api\jaxws-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jws_api\jsr181-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\javax~annotation~api\annotation-api-1.0.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\compilation_lib\sap.com~tc~bl~compilation~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~base_webservices_lib\sap.com~tc~bl~base_webservices_lib.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~base_webservices_lib\jaxm-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~base_webservices_lib\jaxrpc-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~base_webservices_lib\jaxr-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~base_webservices_lib\jaxws-rt.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~base_webservices_lib\jaxws-tools.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~j2eedescriptors~lib\sap.com~tc~je~j2eedescriptors~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~ejb~metadata~model\lib\sap.com~tc~bl~ejb~metadata~model.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\javax~persistence~api\persistence-api-1.0.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\ejbormapping_api\sap.com~tc~je~ejbormapping_api~API.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~orpersistence~metadata~model\sap.com~tc~bl~orpersistence~metadata~model.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~util.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlin~core.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~lib.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~ear.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~connector.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~web.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~ejb.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~appclient.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jlinee~lib\sap.com~tc~jtools~jlinee~orpersistence.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\deploy\sap.com~tc~je~deploy~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\jmx_notification\sap.com~tc~je~jmx_notification~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\runtimeinfo\sap.com~tc~je~runtimeinfo~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\jmx\sap.com~tc~je~jmx~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\jmx\sap.com~tc~je~jmx~impl~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\http\sap.com~tc~je~httpserver~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~exprlang~plb\jee5_el.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jstl\jstl-1_2.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~injection~lib\lib\private\tc~je~injection.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\ec~java~jsf_api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\ec~java~jsf~tld.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\private\com-sun-commons-beanutils.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\private\com-sun-commons-collections.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\private\com-sun-commons-digester.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\private\com-sun-commons-logging-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ec~java~jsf\lib\private\ec~java~jsf_core.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~je~jacc~plb\jacc-1_1-fr-class.zip;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\classpath_resolver\sap.com~tc~je~classpath_resolver~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.ip.basecomps\sap.com~tc~bl~basecomps~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sdo\lib\sap.com~sdo.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sdo\lib\sap.com~sdo~api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sdo\lib\sap.com~sdo~api~extension.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ejb_api\ejb-3_0-api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\webservices_lib\sap.com~tc~je~webservices_lib~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~i18n~saptimezone\sap.com~tc~i18n~saptimezone~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~i18n~cpbase\sap.com~tc~i18n~cpbase~jar~IMPL.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.security.core.sda\sap.com~tc~sec~ume~core~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.security.core.sda\sap.com~tc~sec~ume~tpd~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jms\jms.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\jms\jmsclient.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\com.sap~tc~je~jmsapi\sap.com~tc~je~jmsapi~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\userstore\sap.com~tc~je~userstore~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~SL~utility\sap.com~tc~bl~sl~utility~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\com.sap.exception\sap.com~tc~exception~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc~bl~jarsap~sda\sap.com~tc~bl~jarsap~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\tc~bl~deploy_api\sap.com~tc~bl~deploy~api.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\tc.httpclient\sap.com~tc~clients~http~all.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\tc~sec~destinations~interface\sap.com~tc~sec~destinations~interface_api~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\endpoint_api\sap.com~tc~bl~endpoint~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\connector\sap.com~tc~je~connector~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\antlr\sap.com~tc~antlr~runtime.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\dbpool\sap.com~tc~je~dbpool~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\tc~sec~destinations~provider\sap.com~tc~sec~destinations~provider~java~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\com.sap.security.core.ume.service\sap.com~tc~sec~ume~service~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sap.com~tc~je~constants~lib\lib\tc~je~constants.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\schemaprocessor~srv\sap.com~tc~je~schemaprocessor.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\tc~je~webcontainer~api\sap.com~tc~je~webcontainer~webcontainer_api_impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\servlet_jsp\sap.com~tc~je~webcontainer~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\objectProfiler\sap.com~tc~bl~objectProfiler~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\tc~je~cachemgmt~srv\sap.com~tc~je~cachemgmt~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\locking\sap.com~tc~je~locking~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\configuration\sap.com~tc~je~configuration~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\basicadmin\sap.com~tc~je~basicadmin~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\basicadmin\jstartupapi.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\basicadmin\jstartupimpl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\adminadapter\sap.com~tc~je~adminadapter~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\security\sap.com~tc~je~security~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\applocking\sap.com~tc~je~applocking~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ejb20\ejb20.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ejbqlparser\sap.com~tc~bl~ejbqlparser~lib.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\ejbqlparser\sap.com~tc~bl~ejbqlparser_3_0~lib.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sqlmapper\sap.com~tc~bl~ejbsqlmapper~implCommonSQLMapper.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\sqlmapper\sap.com~tc~bl~ejbsqlmapper~implSQLMapperAPI.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\interfaces\ejbmonitor_api\sap.com~tc~bl~ejbmonitor~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\services\ejb\sap.com~tc~je~ejb~impl.jar;D:\usr\sap\CED\J00\j2ee\cluster\bin\ext\orpersistence_client_lib\lib\orpersistence_client_lib_api.jar;D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\orpersistence\jars\EmployeeEjb.jar;D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\EJBContainer\applicationjars\EmployeeEjb.jar;D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work;;" -nowarn -g ["D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work\JEE_jsp_index_8832250_1231538390011_1231538444324.java"]
    Error stream contains:"D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work\JEE_jsp_index_8832250_1231538390011_1231538444324.java:16: 'class' or 'interface' expected
    import javax.servlet.*;
    ^
    D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work\JEE_jsp_index_8832250_1231538390011_1231538444324.java:17: 'class' or 'interface' expected
    import javax.servlet.http.*;
    ^
    D:\usr\sap\CED\J00\j2ee\cluster\apps\sap.com\EmployeeEar\servlet_jsp\EmployeeWeb\work\JEE_jsp_index_8832250_1231538390011_1231538444324.java:18: 'class' or 'interface' expected
    import javax.servlet.jsp.*;
    ^
    3 errors
    "].005056841108002A00000070000007AC0139C8D8862D3EED Date: 2009-01-09 Time: 23:00:45:042 Category: /System/Server/WebRequests Location: com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl Application: sap.com/EmployeeEar Thread: HTTP Worker [4] Data Source: j2ee\cluster\server0\log\system\server_00.log Correlator ID: 88322500000038637 Argument Objects: Arguments: DSR Component: n.a. DSR Transaction: 10c493a0de9311dd9631005056841108 DSR User: Message Code: Session: 979 Transaction: User: Guest Host: IMGNWCED System: CED Instance: J00 Node: server0
    As you can see there is some compilation error, it says 3 times "'class' or 'interface' expected". If i remove all the relevant EJB java code from my index.jsp everything works fine. So I guess there must be some problem with finding the resources. Unfortunately this "logging" is not helpful at all (thank you SAP!). In NWDS everything is fine no problems at all!!!
    Who can help me here with this?
    Thanks in Advance

    I have found the issue.
    in the index.jsp I have the following lines:
    <!-- Import Statements -->
    <%@ page import="javax.naming.InitialContext" %>
    <%@ page import="com.sap.demo.session.EmployeeServicesLocal;" %>
    Now check the end of the second import ==> ;
    Removing the semicolon solves the issue. But the SAP error message is still not very helpful to me.

  • Urgent: 'Class' or 'interface' expected

    Hello,
    I am working on a piece of work which has to be in for tomorrow, i have been trying to compile it for so,me time now and everytime i try it says 'Class' or 'interface' expected.
    I have not finished writing the program and i am not sure how correct it is. Any help would be much appreciated,
    Thank you,
    James
    Error Message: -
    U:\ManXP\My Documents\myjava>javac emailclient2.java
    emailclient2.java:181: 'class' or 'interface' expected
    private static int readListFromFile(String filename, Message[]
    ^
    messageList, int maxLines)
    1 error

    I am working on a piece of work which has to be in
    for tomorrow, i have been trying to compile it for
    so,me time now and everytime That's quite a bit of superfluous information. Please don't mark your questions as urgent. Thanks!
    i try it says 'Class' or 'interface' expected.You've got a syntax error in your code on line 181. Look at the lines before that. Are you trying to declare that method inside another method?
    Careful adherence to standard Code Conventions for the Java� Programming Language can make this type of problem very easy to spot...

  • JDeveloper Error(16,8) 'class' or 'interface' expected

    I have just installed JDeveloper for 11.5.10 RUP5 OA Framework and extended the Purchase Requisition Lines EO (PoRequisitionLineEO). Everything seemed to work okay. However, in the first step of deployment, to compile the .java class, when I select Make rnPoRequisitionLineEOImpl.java, I receive the following compiler eror:
    Error(16,8): 'class' or 'interface' expected
    My sense is that this may be an environment setup issue as this is the first time I'm using JDeveloper and the first time I am extending OA Framework.
    Any advice on how to resolve?
    Edited by: Kit on Jan 29, 2010 2:42 PM

    This was an end-user error. Additional code had been added to the .java source code that was not in a class.

  • Error like 'class' or 'interface' expected

    hi,
    I write one simple program :-
    enum Apple
            a,b,c;
    public class AppleDemo
            public static void main(String args[])
                    Apple app;
                    app=Apple.a;
                    System.out.println("The Apple is:"+app);
                    app=Apple.b;
                    if(app==Apple.b)
                    System.out.println("Apple is:"+app);
    }My qry is- I am trying to compile this program.I am using j2sdk1.5.0 for compilation...but i got error that is
    *'class' or 'interface' expected*
    Thanks in advance.

    This forum is for Sun Instant Messaging related questions. For simple java questions I suggest you refer to the following forum:
    http://forums.sun.com/forum.jspa?forumID=54
    Regards,
    Shane.

  • Class or interface expected

    I am very new to java and need to do an assignment for my course. I am trying to get a connection to a database and retrieve information but I get the below error when I try to compile my program - any ideas?
    D:\javawork\Bike.java:16: 'class' or 'interface' expected
    public Bike()
    ^
    Here is the actual code:
    //Bike Class
    import java.sql.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    import java.lang.*;
    public class Bike extends JFrame
         private Connection Database;
         private JTable table;
    public Bike()
         // Use JDBC to connect to a Microsoft ODBC source
         String url = "jdbc:odbc:Mikesdb";
         String username = "guest";
         String password = "guest";
         Statement DataRequest;
         ResultSet Results;
         //Load the driver to allow connection to the database
         try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Database = DriverManager.getConnection(url);
              System.out.println("Successful Connection" + Database);
         catch(ClassNotFoundException cnferr)
              System.err.println("Failed to load JDBC/ODBC bridge" + cnferr);
              System.exit(1); //exit program
         catch(SQLException sqlex)
              System.err.println("Unable to connect to the database" + sqlex);
              System.exit(2); //exit program
         FindBike();
         setSize(200,200);
         show();
    public void FindBike(String type, String gender, String status)
         String t = type;
         String g = gender;
         String s = status;
         this.getConnection();
         Statement DataRequest;
         ResultSet Results;
         try
              //get user input for three fields in future
              String query = "Select * FROM Bike WHERE Status = 'Ready'";
              DataRequest = Database.createStatement();
              Results = DataRequest.executeQuery (query);
              displayResults (Results);
              DataRequest.close();
         catch(SQLException err)
              System.out.println("SQL Error: " + err);
              System.exit(3);
    public void Disconnect()
         try
              Database.close();
         catch(SQLException err)
              System.out.println("Cannot close database connection: " + err);
              System.exit(4);
    public static void main(String[] arguments) {
         Bike b = new Bike();
         b.show();
         

    Having moved the { to the end I get lots of new errors!
    D:\javawork\Bike.java:49: FindBike(java.lang.String,java.lang.String,java.lang.String) in Bike cannot be applied to ()
         FindBike();
    ^
    D:\javawork\Bike.java:60: cannot resolve symbol
    symbol : method getConnection ()
    location: class Bike
         this.getConnection();
    ^
    D:\javawork\Bike.java:71: cannot resolve symbol
    symbol : method DisplayResults (java.sql.ResultSet)
    location: class Bike
              DisplayResults (Results);
    ^
    3 errors
    Finished

  • JSP Debbuging -Error: 'class' or 'interface' expected-

    Hi,
    Does anybody know why am I getting the following error when trying to either debug or run a JSP?
    Error: 'class' or 'interface' expected
    This happens with JDeveloper 9.0.2.829
    It was running just OK, when running from the Navigator Panel (Right click -> Run test.jsp)
    But, when I tried to run the JSP from the Debug Icon -that debugs the whole project-, I got the error I already mentioned.
    Thanks in advance for your help
    Agutin

    Hi,
    Does anybody know why am I getting the following error when trying to either debug or run a JSP?
    Error: 'class' or 'interface' expected
    This happens with JDeveloper 9.0.2.829
    It was running just OK, when running from the Navigator Panel (Right click -> Run test.jsp)
    But, when I tried to run the JSP from the Debug Icon -that debugs the whole project-, I got the error I already mentioned.
    Thanks in advance for your help
    Agutin

  • Compile Error: 'class' or 'interface' expected

    Hi all,
    I have a code which was compiling/running successfully:
    import java.net.*;
    code
    When I added the line: import java.io.*;
    import java.net.*;
    import java.io.*;
    code
    Got the following compile error:
    'class' or 'interface' expected
    import java.io.*;
    ^
    If I comment one of my import statements then it compiles, but I can't have both!
    Does anybody know what's the problem? where it comes from?
    Any help is greatly appreciated.

    I haven't post the entire code b/c it's very long, anyway here it is...
    import java.net.*; ;
    import java.io.*;
    //class TransactionOp: #1
    class TransactionOp
    int ID = 0;
    double price = 0.0;
    int subsID = 0;
    String xmlDoc = "";
    String xmlResp = "";
    String respID = "";
    String authCode = "";
    int opResult = 0;
    public TransactionOp(int anID, double aPrice, int aSubID)
         ID = anID;
         price = aPrice;
         subsID = aSubID;     
         //op done values: 1: REF, 2: DCL, 3: AUTH, 4: AUTH_NoID
         //op errors: -1: noResponse, -2: noAuthResp, -3: noStatus, -4: no gw.
    //class AddressCC: #2
    class AddressCC
    String zipcode = "";
    String city = "";
    String state = "";
    String country = "";
    String address1 = "";
    public AddressCC(String addr1, String city1, String state1, String country1, String zipcode1)
         address1 = addr1;
         city = city1;
         state = state1;
         country = country1;
         zipcode = zipcode1;
    //class InfoCC: #3
    class InfoCC
    String fullName = "";
    String number = "";
    String expDate = "";
    public InfoCC(String name, String number1, String date)
         fullName = name;
         number = number1;
         expDate = date;
    public class SurePayGW
    //instance fields
    private String merchant = "";//merchant = aMode
    private String password = "";
    private String server = "";
    private int subsID = 0;
    public SurePayGW()
         merchant = "34593";
         password = "hnbv78hj6";
         server = "xml.surepay.com";     
    }//endof constructor:SurePayGW
    //String formattedS = "\"" + s + "\"";
    public void spitDoc(SurePayGW sp, AddressCC address, InfoCC ccInfo, TransactionOp trans)
         String xmlBuf = "<!DOCTYPE pp.request PUBLIC \"-//IMALL//DTD PUREPAYMENTS 1.0//EN\" \"http://www.purepayments.com/dtd/purepayments.dtd\">";     
         xmlBuf = xmlBuf + "<pp.request merchant=" + "\"" + sp.merchant+ "\" password=" + "\"" + sp.password+ "\">";
         xmlBuf = xmlBuf + "<pp.auth ecommerce=\"true\" ordernumber=" + "\"" + trans.ID + "\" recurring=\"false\">";     
         xmlBuf = xmlBuf + "<pp.creditcard number=" + "\"" + ccInfo.number + "\" expiration=" + "\"" + ccInfo.expDate.charAt(0) + ccInfo.expDate.charAt(1)+ "/" + ccInfo.expDate.charAt(2) + ccInfo.expDate.charAt(3) + "\">";          
         xmlBuf = xmlBuf + "<pp.address type=\"billing\" zip=" + "\"" + address.zipcode + "\" city=" + "\"" + address.city + "\" state=" + "\"" + address.state + "\" country=" + "\"" + address.country + "\" fullname=" + "\"" + ccInfo.fullName + "\" address1=" + "\"" + address.address1 + "\"/>";
         xmlBuf = xmlBuf + "</pp.creditcard>";     
         xmlBuf = xmlBuf + "<pp.address type=\"shipping\" zip=" + "\"" + address.zipcode + "\" city=" + "\"" + address.city + "\" state=" + "\"" + address.state + "\" country=" + "\"" + address.country + "\" fullname=" + "\"" + ccInfo.fullName + "\" address1=" + "\"" + address.address1 + "\"/>";     
         xmlBuf = xmlBuf + "<pp.lineitem sku=\"R" + trans.subsID + "Zg\" description=\"Subscription Renewal\" taxrate=\"0\" quantity=\"1\" unitprice=\"" + trans.price + "USD\"/>";
         xmlBuf = xmlBuf + "</pp.auth></pp.request>";
         //print("@DBG [SurePayDoc.submitTransaction]: will send %s" % xmlBuf)
         trans.xmlDoc= xmlBuf;
         //System.out.println("This the final result of xmlBuf: ");
         //System.out.println(xmlBuf);
         //System.out.println("trans.xmlDoc = " + trans.xmlDoc);
    }//endof m: spitDoc
    public void submitTransaction(SurePayGW sp, TransactionOp aTrans)
         String param = "";
         HttpURLConnection connection;
         URL url;
         String urlString = "";
         String input = "";
         String response = "";
         try
              //params= urllib.urlencode({'xml' : aTrans.xmlDoc})
              param = java.net.URLEncoder.encode(aTrans.xmlDoc, "UTF-8");
              //System.out.println("The output from java.net.URLEncoder.encode: " + param);
              //link= httplib.HTTPSConnection(self.server)
              urlString = "https://" + sp.server;
              url = new URL(urlString);
              connection = (HttpURLConnection)url.openConnection();          
              System.out.println(connection.getURL());          
              System.out.println(connection.getResponseCode() + " " + connection.getResponseMessage());          
              System.out.println(connection.getURL());
              connection.setDoInput(true);
              connection.setDoOutput(true);
              connection.setUseCaches(false);
              //link.putrequest('POST', '/')
         connection.setRequestMethod("POST");
              //link.putheader('Content-type', 'application/x-www-form-urlencoded')
              //link.putheader('Content-length', ("%d" % len(params)))
              //link.putheader('Accept', 'text/plain')
              connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
              connection.setRequestProperty("Content-length", param.length());
              connection.setRequestProperty("Accept", "text/plain");
              //link.endheaders()
              connection.connect();
              System.out.println("Client : Connected");
              //link.send(params)
              //response= link.getresponse()
              //data= response.read()     
              DataOutputStream out = new DataOutputStream(connection.getOutputStream());
              System.out.println("Client : Writing Content");
              out.writeBytes(content);
              System.out.println("Client : Flushing Stream");
              out.flush();
              System.out.println("Client : Waiting for response from Server");
              BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
              System.out.println("Client : Opened input stream");
              while((input = in.readLine()) != null)
                   response += input + "\r";
              System.out.println("Client : received : "+response);
              //I'm not bothering to close the streams or http connection yet.
         }//endof: try
         catch (MalformedURLException e)
              e.printStackTrace();
         catch (Exception e)
              e.printStackTrace();
    }//endof m:submitTransaction
    }//endof class:SurePayGW

  • ERROR: class' or 'interface' expected

    Hello, I'm new to Java. I'm having trouble figuring out this 1 error in my code. Need Help Plzzzzzz....
    java:81: 'class' or 'interface' expected
    public void actionPerformed(ActionEvent e)
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class Checkerboard extends Frame implements ActionListener
         //declare variables
         int start, stop, step;
         Panel boardPanel = new Panel();
         TextArea boardDisplay [] = new TextArea[16];
         Panel buttonPanel = new Panel();
         Button goButton = new Button ("Go");
         Button clearButton = new Button("Clear");
         Panel inputPanel = new Panel();
         Label startLabel = new Label ("Start");
         TextField startField = new TextField();
         Label stopLabel = new Label ("Stop");
         TextField stopField = new TextField();
         Label stepLabel = new Label ("Step");
         TextField stepField = new TextField();
    public Checkerboard()
         this.setLayout(new BorderLayout());
         boardPanel.setLayout(new GridLayout (4, 4, 2, 3));
         inputPanel.setLayout(new FlowLayout());
         buttonPanel.setLayout(new FlowLayout());
              for (int i=0; i<16; i++)
              boardDisplay = new TextArea(null,3,5,3);
              if (i<16)
              boardDisplay[i].getText();
                   else
                   boardDisplay[i].setEditable(false);
                   boardDisplay[i].setBackground(Color.white);
                   boardPanel.add(boardDisplay[i]);
    //add components to the button
    buttonPanel.add(goButton);
    //add components to input panel
    inputPanel.add(startField);
    inputPanel.add(stopField);
    inputPanel.add(stepField);
    inputPanel.add(startLabel);
    inputPanel.add(stopLabel);
    inputPanel.add(stepLabel);
    //add panels to frame
    add(buttonPanel, BorderLayout.SOUTH);
    add(inputPanel, BorderLayout.CENTER);
    add(boardPanel, BorderLayout.NORTH);
    goButton.addActionListener(this);
    addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent e)
              System.exit(0);
         }//end Checkerboard frame
    public void actionPerformed(ActionEvent e)
         String arg = e.getActionCommand();
         try
              if (arg == "GO")
                   start=Integer.parseInt(startTF.getText());
                   stop=Integer.parseInt(stopTF.getText());
                   step=Integer.parseInt(stepTF.getText());
                   for(int i=0;<textArray.length;i++)
                   textArray[i].setBackground(Color.blue);
                   for(int i=start;<textArray.length;i+=step)
                   textArray[i].setBackground(Color.yellow);
              catch(Exception x)
                   JOptionPane.showMessageDialog(null,"Data Entry Error","Error",JOptionPane.INFORMATION_MESSAGE);
                   arg = "Clear")
                   startTF.setText("");
                   stopTF.setText("");
                   stepTF.setText("");
                   for(int i=0;<textArray.length;i++)
                   textArray[i].setBackground(Color.white);
         }//end actionPerformed
         public static void main(String[]args)
              Checkerboard f = new Checkerboard();
              f.setBounds(50,100,300,300);
              f.setTitle("Checkerboard Array");
              f.setVisible(true);
         }//end main method
    }//end Checkerboard class

    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class Checkerboard extends Frame implements ActionListener
         //declare variables
         int start, stop, step;
         Panel boardPanel = new Panel();
              TextArea boardDisplay [] = new TextArea[16];
         Panel buttonPanel = new Panel();
              Button goButton = new Button ("Go");
              Button clearButton = new Button("Clear");
         Panel inputPanel = new Panel();
              Label startLabel = new Label ("Start");
              TextField startField = new TextField();
              Label stopLabel = new Label ("Stop");
              TextField stopField = new TextField();
              Label stepLabel = new Label ("Step");
              TextField stepField = new TextField();
    public Checkerboard()
         this.setLayout(new BorderLayout());
              boardPanel.setLayout(new GridLayout (4, 4, 2, 3));
              inputPanel.setLayout(new FlowLayout());
              buttonPanel.setLayout(new FlowLayout());
              for (int i=0; i<16; i++)
                   boardDisplay = new TextArea(null,3,5,3);
              if (i<16)
                        boardDisplay[i].getText();
                   else
                        boardDisplay[i].setEditable(false);
                        boardDisplay[i].setBackground(Color.white);
                        boardPanel.add(boardDisplay[i]);
    //add components to the button
    buttonPanel.add(goButton);
    //add components to input panel
    inputPanel.add(startField);
    inputPanel.add(stopField);
    inputPanel.add(stepField);
    inputPanel.add(startLabel);
    inputPanel.add(stopLabel);
    inputPanel.add(stepLabel);
    //add panels to frame
    add(buttonPanel, BorderLayout.SOUTH);
    add(inputPanel, BorderLayout.CENTER);
    add(boardPanel, BorderLayout.NORTH);
    goButton.addActionListener(this);
    addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
         }//end Checkerboard frame
    public void actionPerformed(ActionEvent e)
         String arg = e.getActionCommand();
         try
              if (arg == "GO")
                   start=Integer.parseInt(startTF.getText());
                   stop=Integer.parseInt(stopTF.getText());
                   step=Integer.parseInt(stepTF.getText());
                   for(int i=0;<textArray.length;i++)
                   textArray[i].setBackground(Color.blue);
                   for(int i=start;<textArray.length;i+=step)
                   textArray[i].setBackground(Color.yellow);
              catch(Exception x)
                   JOptionPane.showMessageDialog(null,"Data Entry Error","Error",JOptionPane.INFORMATION_MESSAGE);
                   arg = "Clear")
                   startTF.setText("");
                   stopTF.setText("");
                   stepTF.setText("");
                   for(int i=0;<textArray.length;i++)
                   textArray[i].setBackground(Color.white);
         }//end actionPerformed
         public static void main(String[]args)
              Checkerboard f = new Checkerboard();
              f.setBounds(50,100,300,300);
              f.setTitle("Checkerboard Array");
              f.setVisible(true);
    }//end main method
    }//end Checkerboard class                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 'class' or 'interface' expected, advice please!

    Hi! I have problems running a program. it is supposed to 1) open a file 2) find word 1-3, 2-4, 3-5 a.s.o. 3) write the wordstrings it found in a system.out.println. In the former version, I only had private static void and got this: Exception in thread "main" java.lang.NoSuchMethodError: main when i ran it. I was adviced to add public static void but now it says: 'class' or 'interface' expected, does someone know why this is?
    this is what the code looks like:
    import java.io.*;
    import java.io.*;
    import java.util.*; //tillagd f�r att removeFirst4 skall funka
    import javax.swing.*; //tillagd f�r att removeFirst4 skall fungera
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.lang.*;
    import javax.swing.*;
    public static void main(String[] foo) {
    public class AttLaesaEnFil2 {
         private static void main(String name, BufferedReader in) throws
         IOException {
         String a;
         WordExtractor b;
    String c = " ";
    String d;
    WordExtractor e;
    String f;
    String g;
    WordExtractor h;
    String i;
    String j;
    String k;
    String l;
    String line;
    do {
                   line = in.readLine();
                   if (line != null)
    b = new WordExtractor(line);
         c = b.getFirst();
         d = b.getRest();
         e = new WordExtractor(d);
         f = e.getFirst();
         g = e.getRest();
         h = new WordExtractor(g);
         i = h.getFirst();
         j = h.getRest();
         k = c + f + i;
         l = c + " " + f + " " + i;
    System.out.println("The first three words are: " + l);
         a = b.getRest();
    while (line != null);
              System.out.println("Klart!");
              private static void main(String fileName) {
              BufferedReader in = null;
              try {
                   FileReader fileReader = new FileReader(fileName);
                   in = new BufferedReader(fileReader);
                   main(fileName, in);
              } catch (IOException ioe) {
                   ioe.printStackTrace();
              } finally {
                   if (in != null) {
                        try {
                             in.close();
                        } catch (IOException ioe) {
                             ioe.printStackTrace();
         private static void main(String streamName, InputStream input) {
              try {
                   InputStreamReader inputStreamReader = new InputStreamReader(input);
                   BufferedReader in = new BufferedReader(inputStreamReader);
                   main(streamName, in);
                   in.close();
              } catch (IOException ioe) {
                   ioe.printStackTrace();
    i tried to add public static void before each private but with the same result.
    Thank you in advance

    This wins the award for Funniest Code Snippet of the
    Day. Four main methods, with a class nested inside
    the first main method.Hey! stop mocking me, i'm doing my best!
    this is the code i'm learning this from, it also includes four methods (not main though, maybe that's the pr.) but works fine but mine still won't:
    import java.io.*;
    * Command line program to count lines, words and characters
    * in files or from standard input, similar to the wc
    * utility.
    * Run like that: java WordCount FILE1 FILE2 ... or
    * like that: java WordCount < FILENAME.
    * @author Marco Schmidt
    public class WordCount {
         * Count lines, words and characters in given input stream
         * and print stream name and those numbers to standard output.
         * @param name name of input source
         * @param input stream to be processed
         * @throws IOException if there were I/O errors
         private static void count(String name, BufferedReader in) throws
         IOException {
              long numLines = 0;
              long numWords = 0;
              long numChars = 0;
              String line;
              do {
                   line = in.readLine();
                   if (line != null)
                        numLines++;
                        numChars += line.length();
                        numWords += countWords(line);
              while (line != null);
              System.out.println(name + "\t" + numLines + "\t" +
                   numWords + "\t" + numChars);
         * Open file, count its words, lines and characters
         * and print them to standard output.
         * @param fileName name of file to be processed
         private static void count(String fileName) {
              BufferedReader in = null;
              try {
                   FileReader fileReader = new FileReader(fileName);
                   in = new BufferedReader(fileReader);
                   count(fileName, in);
              } catch (IOException ioe) {
                   ioe.printStackTrace();
              } finally {
                   if (in != null) {
                        try {
                             in.close();
                        } catch (IOException ioe) {
                             ioe.printStackTrace();
         * Count words, lines and characters of given input stream
         * and print them to standard output.
         * @param streamName name of input stream (to print it to stdout)
         * @param input InputStream to read from
         private static void count(String streamName, InputStream input) {
              try {
                   InputStreamReader inputStreamReader = new InputStreamReader(input);
                   BufferedReader in = new BufferedReader(inputStreamReader);
                   count(streamName, in);
                   in.close();
              } catch (IOException ioe) {
                   ioe.printStackTrace();
         * Determine the number of words in the argument line.
         * @param line String to be examined, must be non-null
         * @return number of words, 0 or higher
         private static long countWords(String line) {
              long numWords = 0;
              int index = 0;
              boolean prevWhitespace = true;
              while (index < line.length()) {
                   char c = line.charAt(index++);
                   boolean currWhitespace = Character.isWhitespace(c);
                   if (prevWhitespace && !currWhitespace) {
                        numWords++;
                   prevWhitespace = currWhitespace;
              return numWords;
         public static void main(String[] args) {
              if (args.length == 0) {
                   count("stdin", System.in);
              } else {
                   for (int i = 0; i < args.length; i++) {
                        count(args);

  • Class or interface expected in Javabeans

    Hi Netbeans Guru,
    I have run out of ideas when trying to run the Juggler example below from Chapter 22: JavaBeans, Learning Java published by Oreilly in
    Netbeans 5.0, Windows XP:
    * LearningJava1.java
    * Created on 3 August 2006, 02:59
    * @author abc
    import javax.swing.*
    public class LearningJava1 extends javax.swing.JFrame {
    /** Creates new form LearningJava1 */
    public LearningJava1() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
    juggler1 = new magicbeans.sunw.demo.juggler.Juggler();
    jButton1 = new javax.swing.JButton();
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    juggler1.setAnimationRate(500);
    org.jdesktop.layout.GroupLayout juggler1Layout = new org.jdesktop.layout.GroupLayout(juggler1);
    juggler1.setLayout(juggler1Layout);
    juggler1Layout.setHorizontalGroup(
    juggler1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(0, 144, Short.MAX_VALUE)
    juggler1Layout.setVerticalGroup(
    juggler1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(0, 125, Short.MAX_VALUE)
    getContentPane().add(juggler1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 70, -1, -1));
    jButton1.setText("Start");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 220, -1, -1));
    pack();
    }// </editor-fold>//GEN-END:initComponents
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    juggler1.setJuggling(true);
    }//GEN-LAST:event_jButton1ActionPerformed
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new LearningJava1().setVisible(true);
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private magicbeans.sunw.demo.juggler.Juggler juggler1;
    // End of variables declaration//GEN-END:variables
    This program failed to compiled with the message "Class or interface expected" when declaring the JavaLearning1 constructor (line 17) and the private juggler1 variable (last line of code). It is not possible to see the code within initComponents methods in Netbeans Source Workspace. Is it possible that this is due to CLASSPATH not set correctly?
    I am new to JavaBeans and would appreciate any guidances.
    Many Thanks,
    Netbeans Fan

    Hi itchyscratchy,
    Thanks for pointing the missing semi colon out but it was just a copy & paste error. The import statement does have the semi colon in it. Nevertheless, below is the output when compiling from Netbeans:
    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\abc\Java Tutorial\build\classes
    C:\Documents and Settings\abc\Java Tutorial\src\LearningJava1.java:17: 'class' or 'interface' expected
    public LearningJava1() {
    C:\Documents and Settings\abc\Java Tutorial\src\LearningJava1.java:76: 'class' or 'interface' expected
    private magicbeans.sunw.demo.juggler.Juggler juggler1;
    C:\Documents and Settings\abc\Java Tutorial\src\LearningJava1.java:79: 'class' or 'interface' expected
    C:\Documents and Settings\abc\Java Tutorial\src\LearningJava1.java:80: 'class' or 'interface' expected
    4 errors
    BUILD FAILED (total time: 1 second)
    Thanks,
    Netbeans Fan

  • 'class' or 'interface' expected" on Connection class in java.sql.*

    I am currently getting an exception "Main.java:20: 'class' or 'interface' expected". I had the database connection working, but then I tried to add something else and I feel like I might have changed something. I am wondering if there is a problem importing the java.sql. library; since that is where the Connection class is located. Thanks for your feedback.
    package javaaaplication2;
    import java.sql.*;
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
        public static void main(String[] args) {
            Connection con = getConnection();
            System.out.println("The connection is: " +con );
        private static Connection getConnection()
                Connection con = null;
                try
                    Class.forName("com.mysql.jdbc.Driver");
                    String url = "jdbc:mysql://localhost/patients";
                    String user = "root";
                    String pw = "qwerty";
                    con = DriverManager.getConnection(url, user, pw);
                catch (ClassNotFoundException e)
                    System.out.print(e.getMessage());
                    System.exit(0);           
                catch (SQLException e)
                    System.out.print(e.getMessage());
                    System.exit(0);
                return con;
        }

    You closed your Main class with a bracket, so your getConnection() method isn't in a class
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
        public static void main(String[] args) {
            Connection con = getConnection();
            System.out.println("The connection is: " +con );
    }That is your entire Main class. Anything below it isn't in the class.

  • How to Fix ''The messaging interface has returned an unknown error. If the problem persists, restart Outlook.' Error

    How to Fix ''The messaging interface has returned an unknown error. If the problem persists, restart Outlook.' Error, user has outlook 2007 connected to exchange 2010 server , I tried scan pst, configuring new profile but no luck so far. Please suggest !
    Aditya Mediratta

    Hi,
    Please try the steps mentioned below and check if it helps:
    Open Computer > Local Disk C > Program Files > Microsoft Office > Office 12 > Outlook.exe.
    Right click on outlook.exe and click on Properties and then click on
    Compatibility tab. Uncheck the box ‘run this program in compatibility mode for’ under compatibility mode, click on Apply and OK.
    Note: If you are using 64 bit computer then the file location of the file will be
    Computer>Local Disk C>Program Files (x86) >Microsoft Office>Office 12>Outlook.exe
    Similar thread:
    https://social.technet.microsoft.com/Forums/en-US/aa396c9e-0ce5-4de5-99e3-4f0d771b07e0/exchange-2007-messaging-interface-has-returned-an-unknown-error
    Best Regards.

  • Unable to resolve 'class' or 'interface' expected compile error

    Any help would be appreciated - I can't resolve the following compile errors:
    E:\j2sdk1.4.0\bin\RandomApp3\src\RandomApp3.java:85: 'class' or 'interface' expected private void initComponents() {
    E:\j2sdk1.4.0\bin\RandomApp3\src\RandomApp3.java:97: 'class' or 'interface' expected }
    E:\j2sdk1.4.0\bin\RandomApp3\src\RandomApp3.java:97: 'class' or 'interface' expected }
    3 errors
    here is the source:
    import javax.swing.JOptionPane;
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.util.Random;
    public class RandomApp3 extends javax.swing.JApplet {
    public RandomApp3() {
    public static void main(String args[]) {
    /** Creates a new instance of RandomApp3 */
    public class RandInt {
    private Random randNum;
    //constructor for RandInt class
    public RandInt(int endInt) {
    int randNum;
    int range;
    int[] lottery = new int[5];
    for (int x = 0; x <=49; x++) {
    range = (int) (Math.floor(Math.random()*5 + 1));
    lottery[range]++;
    /** Initializes the applet RandomApp3 */
    public void initComponents() {
    try {
    java.awt.EventQueue.invokeAndWait(new Runnable() {
    public void run() {
    initComponents();
    } catch (Exception ex) {
    ex.printStackTrace();
    /** This method is called from within the init() method to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    panell = new java.awt.Panel();
    getContentPane().add(panell, java.awt.BorderLayout.CENTER);
    // </editor-fold>
    // Variables declaration - do not modify
    private java.awt.Panel panel1;
    // End of variables declaration
    /** This method is called from within the init() method to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    panel1 = new java.awt.Panel();
    getContentPane().add(panel1, java.awt.BorderLayout.CENTER);
    // </editor-fold>
    // Variables declaration - do not modify
    private java.awt.Panel panel1;
    // End of variables declaration
    }

    Re-posted with code tags. This may show that there is an extra } just before initComponents()
    public class RandomApp3 extends javax.swing.JApplet {
    public RandomApp3() {
    public static void main(String args[]) {
    /** Creates a new instance of RandomApp3 */
    public class RandInt {
    private Random randNum;
    //constructor for RandInt class
    public RandInt(int endInt) {
    int randNum;
    int range;
    int[] lottery = new int[5];
    for (int x = 0; x <=49; x++) {
    range = (int) (Math.floor(Math.random()*5 + 1));
    lottery[range]++;
    /** Initializes the applet RandomApp3 */
    public void initComponents() {
    try {
    java.awt.EventQueue.invokeAndWait(new Runnable() {
    public void run() {
    initComponents();
    } catch (Exception ex) {
    ex.printStackTrace();
    /** This method is called from within the init() method to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    panell = new java.awt.Panel();
    getContentPane().add(panell, java.awt.BorderLayout.CENTER);
    // </editor-fold>
    // Variables declaration - do not modify
    private java.awt.Panel panel1;
    // End of variables declaration
    /** This method is called from within the init() method to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    panel1 = new java.awt.Panel();
    getContentPane().add(panel1, java.awt.BorderLayout.CENTER);
    // </editor-fold>
    // Variables declaration - do not modify
    private java.awt.Panel panel1;
    // End of variables declaration
    }

  • Java :27 class enum,interface expected

    hi all
    this code return error java:27 class enum,interface expected when run
    what wrong with it ?
    thank you
    denny
    //Find Maximum of 2 nos.
    class Maxof2{
      public static void main(String args[]){
          //taking value as command line argument.
          //Converting String format to Integer value
          int i = Integer.parseInt(args[0]);
          int j = Integer.parseInt(args[1]);
          if(i > j)
              System.out.println(i+" is greater than "+j);
          else
              System.out.println(j+" is greater than "+i);
    }

    hello all
    i find one more line at the bottom of the code ( I just copy paste from the website which give example ,and more then code area copied)
    after i remove that line
    It ok now it compiled smoothly wjthout error but now it return error when run
    the error message is :
    Exception in thread "main" java.lang.ArrayIndexOutOfboundsException: 0 at Maxof2.main(Maxof2.java:15)
    uuh how difficult java is
    denny
    tq

Maybe you are looking for