Java class access modifiers

Why java class cannot have private and protected access modifiers?

class X {
  private class y {}
}should compile just fine. A top-level private class makes no sense because you wouldn't be able to see it. As for protected, I don't know.

Similar Messages

  • Default class access modifier

    What is the default access modifier for a class? I can't seem to find it in the tutorials...
    Thanks
    Jim

    The default access is the same for top level classes that do not specify access explicitly as for other identifiers. Package.
    This single source file will create two class files in the same package. Only other classes in the package can see these top level package access classes.
    And, yes, this is a bad idea. In the case of some build tools, errors in a compile can cause the public class to compile, but the package class to fail. After that, the compiler will not be able to determine what source file to compile for the package level class. This is an error that confuses many developers. I do not recommend this practice. Put each top level class in its own source file.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Understanding Java Class Accessibility

    I don't understand what makes a Java library class accessible by a Java applet. If an applet has an import statement that imports, say, java.util.TreeMap, then when a web browser accesses a web page containing that applet, does it download the Java code for the TreeMap class at that time, and if so, does that mean that you have to package the TreeMap class as part of your applet class code somehow? Or, must the TreeMap class be installed as part of the Java virtual machine on the computer that is running the browser? If the latter, what determines whether or not the typical computer will have the TreeMap class available? Is the TreeMap class available on a PC running Windows XP, using the Java virtual machine that Microsoft supplies? Where can I read about this sort of thing? How can I determine what classes I can safely use if I want my applet to run on both Windows and Macs?

    "I don't understand what makes a Java library class accessible by a Java applet. If an applet has an import statement that imports, say, java.util.TreeMap, then when a web browser accesses a web page containing that applet, does it download the Java code for the TreeMap class at that time, and if so, does that mean that you have to package the TreeMap class as part of your applet class code somehow? "
    No.
    "Or, must the TreeMap class be installed as part of the Java virtual machine on the computer that is running the browser?"
    Yes
    "If the latter, what determines whether or not the typical computer will have the TreeMap class available?"
    The version of the Java Runtime environment/Plug-in installled on the PC
    "Is the TreeMap class available on a PC running Windows XP, using the Java virtual machine that Microsoft supplies?"
    No which why some people don't use the newer Java classes or Swing when they write applets.
    "Where can I read about this sort of thing? How can I determine what classes I can safely use if I want my applet to run on both Windows and Macs?"
    http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html

  • ClassCastException when any seeded java class is modified

    Dear,
    I am working on making some changes on iProcurement ShoppingCartPG.
    I have project set in JDeveloper and can run the ShoppingHomePG and CheckoutSummaryPG from JDeveloper.
    The problem is - as soon as I include the controller for any of these pages, for example, CheckoutSummaryCO.java, and make a smallest change there, just add an empty line or put any System.out.println("********"); statement I am getting an error
    oracle.apps.fnd.framework.OAException: java.lang.ClassCastException
    (full stack below). What is wrong?
    Thank you.
    Anatoliy
    oracle.apps.fnd.framework.OAException: java.lang.ClassCastException
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891)
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:865)
         at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(OAException.java:988)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:211)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:133)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:784)
         at oracle.apps.icx.por.common.webui.ClientUtil.getPorSystemInfo(ClientUtil.java:319)
         at oracle.apps.icx.icatalog.shopping.webui.ShoppingHomeCO.processRequest(ShoppingHomeCO.java:158)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1136)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
         at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2335)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1734)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
         at OA.jspService(OA.jsp:34)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    ## Detail 0 ##
    java.lang.ClassCastException
         at oracle.apps.icx.por.common.server.SystemInfoHelper.getPorSystemInfo(SystemInfoHelper.java:130)
         at oracle.apps.icx.por.common.server.SystemInfoAMImpl.getPorSystemInfo(SystemInfoAMImpl.java:54)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:133)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:784)
         at oracle.apps.icx.por.common.webui.ClientUtil.getPorSystemInfo(ClientUtil.java:319)
         at oracle.apps.icx.icatalog.shopping.webui.ShoppingHomeCO.processRequest(ShoppingHomeCO.java:158)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1136)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
         at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2335)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1734)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
         at OA.jspService(OA.jsp:34)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    java.lang.ClassCastException
         at oracle.apps.icx.por.common.server.SystemInfoHelper.getPorSystemInfo(SystemInfoHelper.java:130)
         at oracle.apps.icx.por.common.server.SystemInfoAMImpl.getPorSystemInfo(SystemInfoAMImpl.java:54)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:133)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:784)
         at oracle.apps.icx.por.common.webui.ClientUtil.getPorSystemInfo(ClientUtil.java:319)
         at oracle.apps.icx.icatalog.shopping.webui.ShoppingHomeCO.processRequest(ShoppingHomeCO.java:158)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1136)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
         at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2335)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1734)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
         at OA.jspService(OA.jsp:34)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)

    Hi asmirnov,
    If i'm not mistaken, I believe this happens because all iProcurement page controllers extend a common "base" controller, and the call to super.processRequest() must reference something on ShoppingHomeCO... check the controller you are changing for an inheritance declaration, and then follow the hierarchy to find out where lies the dependency.
    Best thing to do, however, would be to create a JAR with the whole iProcurement flow you are changing, for example, oracle.apps.icx.por.shopping (and everything below, including server and webui packages), then you are safer.
    Regards
    Thiago

  • Access modifiers

    I dint understood the below question properly, please help me out.......
    You want subclasses in any package to have access to members of a superclass. Which is
    the most restrictive access that accomplishes this objective?
    A. public
    B. private
    C. protected
    D. transient
    E. default access
    I want to know whether the question is relating to class access modifiers or methods and variables of the classes...

    I didnt get you, please explain the topic properly.... I think classes can have only public and default as an access modifier, is it rite??? That's right. Look at [this,|http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html] it will give you a better understanding of the topic than you'd get from me answering your question.

  • Access Modifiers, Package declaration

    I created the following two classes in the same folder as two source files:
    A.java
    package abc;
    class A{
    B.java
    package abc;
    class B extends A{
    When I tried to compile, A compiled successfully. But when compiling B, it gives an error Cannot find symbol for class A.... I think it should be visible as both class access modifiers are (default). Why do I get this error????
    By the way if package declarations are removed from both classes then they compile successfully........

    i tried a lot..... does classpath affects compilation??? can u correct dis???If we're going to make the effort to help you, you could show willing and make the effort to spell out all your words and generally make your sentences as easy to understand as possible.
    Yes, the classpath affects compilation as the link provided shows. YOU can correct this.
    >
    e:\one\>javac -classpath e:\one\cert B.java
    >
    The classpath points at directories (or JAR files) not Java source files. Read the link.

  • Map xsd complex type to existing java class without adding JAXB annotations

    Hello
    I've got a case where I should map an xsd complex type to an existing Java class without modifying that class, i.e. without adding JAXB annotations to that class.
    Is this possible somehow?
    As far as I've understood, the <javaType> declaration (adapter, parse/print methods) can only be used for xsd simple types.
    Thanks, Tom

    It should be possible to implement an XmlAdapter<...,...> which performs the required conversion between the original type and a JAXB-annotated type. Then, at the places where the original type is used, the @XmlJavaTypeAdapter annotation would be used.
    The xjc compiler supports this for xsd simple types (xjc:javaType annotation), but not for complex types.
    Any idea why this is restricted to simple types?
    Would it be possible to implement a xjc plugin which does this for complex types?
    Thanks Tom.

  • Java inner class access specifiers

    public class MyClass1 {
    public static void main(String argv[]){ }
    /*Modifier at XX */ class MyInner {}
    What modifiers would be legal at XX in the above code?
    1) public
    2) private
    3) static
    4) friend

    Iam a newbie to javaI don't care. I still assume you have a brain and expect you to use it.
    and iam struck with this
    question, iam getting a compile time error for any
    access specifiers mentioned as options, but the
    answers given by my superior are 1,2,3, are
    correct..Then you made a typo or whatever. Make sure you eliminate the problems that are not "illegal access modifier" errors.
    What good is knowing the reply to this if you can't even write an example?

  • Acces specifiers and Access Modifiers in java

    what are Access specifiers?
    what are Access modifiers?
    Whether both of them are same or is there any difference?

    As far as I know "access specifier" == "access modifier".
    To me, they both mean "the Java Language word which specifies the visibility of a class or class attribute".
    http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
    ... but I'm no expert.
    Cheers.

  • Java class bean can not access to DB in JSP file

    Hi, I wrote a java class bean in order to access to MySql database ,and this bean is used in a JSP file,so that the bean can query from DB and then display the queried information on the JSP file,but it can not work correctly,the following is the source code and error message popup by the system,
    does anybody has experience in solving thus question,Please reply ,Thank you for your help.
    %@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page import = "java.sql.*" %>
    <jsp:useBean id="conn" scope="page" class="news.conn"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>1</title>
    <style>
    <!--
    A:link {
         COLOR: #993399
    .s {
         FONT-SIZE: 13px; LINE-HEIGHT: 170%; FONT-FAMILY: "utf-8"
    -->
    </style>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
    <tr>
    <td width="100%">
    <img border="0" src="images/ruanjian.jpg" width="770" height="154"></td>
    </tr>
    <tr>
    <td width="100%">@</td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
    <tr>
    <td width="13%">@</td>
    <td width="87%">
    <img border="0" src="images/mid-rdxw2.gif" width="101" height="18"><p>
    <%
              ResultSet rs,rsNest;
    String strSql=null;
    strSql = "select * from news where TYPE=1";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt(id")%">"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>
    <img border="0" src="images/mid-hyxw2.gif" width="94" height="19"></p>
    <%
    strSql="select * from news where TYPE=2";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt("id")%>"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>@</td>
    </tr>
    </table>
    <p align="center">Study Online</p>
    <p align="center">@</p>
    </body>
    </html>
    Error message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Exception in JSP: /newsMain.jsp:47
    44: strSql = "select * from news where TYPE=1";     
    45:           rs = conn.executeQuery(strSql);
    46:           
    47:           while (rs.next()){
    48:
    49: %>
    50:
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    root cause
    java.lang.NullPointerException
         org.apache.jsp.newsMain_jsp._jspService(newsMain_jsp.java:98)
         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:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 l</a>

    nogoodatcoding wrote:
    Tolls wrote:
    Is that Jasper Exception telling us where the problem is in the jsp, though?
    If it is, then "rs" is null in the call rs.next()...which means conn.executeQuery() is returning null. Which means that whatever class conn is (news.conn?) has a problem maybe?That's possible. Though, it may just be the case that the 'conn' object itself is null! That line is the first place where it's being used and there are no checks that I can see...we'll have to wait for the OP to investigate and reply I guess.That's what I originally thought, then I noticed it was saying line 47, which is the rs.next() line. Assuming Jasper is correct in its choice of line, then it's the rs that's null. Which means the conn is doing strange things.
    Edit: Now that I think about it, going by the previous thread the OP posted, I'm wondering whether news.conn class is their attempt to move the JDBC stuff out of the JSP page, and it's grabbing the "real" connection (java.sql.Connection) and getting the result set and returning it...or getting something wrong and returning null.
    Edited by: Tolls on 11-Jun-2009 12:24

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • Help me which JNDIFactory to use to access EJB from a java class of JAR

    I am confused in understanding the different JNDI factories
    RMIInitialContextFactory, ApplicationInitialContextFactory and ApplicationClientInitialContextFactory
    And the different namespaces like global, container local and component local.
    Especially is there any relationship between the JNDI factories and the namespaces?
    Or are they related to the deployment descriptors.
    Because in application specific deployment descriptors (orion-ejb-jar.xml), we just map the JNDI location with the object (or its reference from ejb-jar.xml). We dont specify it can be accessed from this factory or that.
    Shall we access an EJB from using any JNDI factory?
    Specifically, I am stuck with what Factory to use to access an EJB from a Java class in a library (jar). The JAR is packaged with the EAR which contains the EJB Jar that I am trying to access.
    THANK YOU

    Ed,
    As Robin said, I think you need code similar to this:
    Context c = new InitialContext();
    Object o = c.lookup("java:comp/env/Name");where Name is the name of your EJB as it appears in the "ejb-jar.xml"
    deployment descriptor XML file.
    Good Luck,
    Avi.

  • How to get access to PageContext in a java class (.java file)?

    Hi all,
    I am trying to get access to PageContext from inside a java class, and it doesn't seem to work.
    I could get the PageContext from a jsp page, at the object instantiation, through the constructor, but my class is not called by a jsp page.
    Any ideas?
    Thanks,
    Paul

    Basically I do not need to change any attributes from pageContext. However I need the pageContext object because I am using a third party component that is initialized with the pageContext .
    I cannot change the implementation of that component: it is a black box to me, I simply need the pageContext in my java class that uses the component.
    Any thoughts based on this clarification?
    Thanks,
    Paul

  • PI 7.1 Access to Dynamic Configuration through Java Class

    My Current scenario involves IDCO -> FILE communications in PI 7.1 using XSL where the file name is dynamic.
    I have attempted calling a Java Class from XSL with the use SAPXMLTOOL kit option set in the adaptor and it works but I need to be able to call the transform method
    public void transform(TransformationInput arg0, TransformationOutput arg1)
    from XSL so I can access the message and update the File Name via Dynamic Configuration.
    Whilst I can call a static class with in the object I can not call transform with the correct arguments (arg0, arg1). I need access to arg0 (payload) to set/figure out the filename. I can calculate the filename in XSL and pass it to the Java but in a static method it is useless as it need to access the arg0 which is a object and obviously non-static context.
    Is this possible ? How do I get access to Dynamic Configuration from XSL through Java in 7.1 ?
    I have successfully called a static method but that is no help.
    Thanks in advance.

    Suraj,
       Unfortunately you link isnt operational but thankyou anyway, I have managed to call as Java class as per my original post, but a static method does not allow me to get a handle to the Dynamic Configuration Variables in the message.
    It seems importing the 7.0 LIBS may be an option and Im not entirely sure I have that option.
    It certainly isnt possible to use the JDK5 XML implementation to even call a static method on an Java OBJ from XSL (obviously the USE SAPXMLTOOLKIT option is there for a reason).
    I think and again I could be wrong but direct access via XSLT..
    LINK:http://help.sap.com/saphelp_nwpi71/helpdata/EN/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    Is what Im looking for, I shall report back success or failure but the doco seems to fit the bill. Im not sure why I wanted to instatiate a sperate Java class when it can all exist in the XSLT.

Maybe you are looking for