Servlet compile error why?

Hi!
All day I was trying to compile a java servlet, but I always get error message. My java file is the following: (PetiServlet.java)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class PetiServlet extends HttpServlet {
When I try to compile (javac PetiServlet.java), get the following error message:
C:\j2sdk1.4.1_01\temp>javac PetiServl
PetiServlet.java:2: package javax.ser
import javax.servlet.*;
^
PetiServlet.java:3: package javax.ser
import javax.servlet.http.*;
^
PetiServlet.java:5: cannot resolve sy
symbol : class HttpServlet
location: class PetiServlet
public class PetiServlet extends Http
^
3 errors
Ok, I have installed the j2sdk1.4.1_01 , the jsdk2.0, the j2ee. I have the servlet.jar file in my classpath c:\j2sdk1.4.1_01\classpath
CLASSPATH="C:\JSDK2.0\lib\";c:\j2sdk1.4.1_01\classpath;
JAVA_HOME=c:\j2sdk1.4.1_01;
Its seems everything ok, but what's wrong?
Thank you! Peter

Try this,
javac -classpath C:\JSDK2.0\lib\;.;C:\j2sdk1.4.1_01\classpath\servlet.jar PetiServlet.java
The basic idea is, you need to add each jar file independently into classpath. Adding the folder into classpath is just not sufficient.
Sudha

Similar Messages

  • Compilation error, why???

    this procedure always generate compilation error listed below, I don't understand, anyone has a clue?? Thanks!!!
    LINE/COL ERROR
    3/18 PLS-00103: Encountered the symbol "(" when expecting one of the
    following:
    := . ) , @ % default character
    The symbol ":=" was substituted for "(" to continue.
    create or replace procedure test1234 (
    v_project projects.id%TYPE,
    v_yesno char(1)) as
    cursor c_table is
    select table_name from user_tab_columns
    where column_name = 'PRO_ID'
              and table_name not like '%_DEL'
         and table_name not like '%_REP'
              and table_name not like 'USER_%'
              and table_name not like '%_OLD'
              and table_name not like '%_TEST'
              and table_name not like 'DAVID%'
              and table_name not like '%_BAK';
    v_table           varchar(30);
    child_table           varchar(30);
    parent_table          varchar(30);
    v_count           number(15);
    l_count           number(15);
    child_count           number(15);
    tbl_count           number(15);
    begin

    You must n ot specify the length of the string in the declaration.
    Thats why line 3 has to be:
         v_yesno char) asHTH
    Jens

  • Java Servlet compile error

    I have written a little servlet program. When it is compiled, I get errors saying "javax.servlet does not exist".
    I have J2EE SDK 1.4 installed. Does the error mean the classpath is missing? Appreciate advise.

    Hi !
    I had same error yesterday. But later I was able to compile the servlet by setting CLASSPATH.
    Set CLASSPATH as follows if you have installed J2EE AppServer in c:\
    1. Locate j2ee.jar in the directory you installed J2EE AppServer which can be in:
    C:\Sun\AppServer\lib\j2ee.jar
    2. Go to My Computer properties
    3. Click on the Environmental variable button of Advanced tab
    4. If you already have CLASSPATH variable then click on Edit button else click on New to set the CLASSPATH as follows:
    CLASSPATH=C:\Sun\AppServer\lib\j2ee.jar
    I think this should work for you.
    Goodluck,
    Anurag

  • Compile error, WHY??

    I am trying to use:
    private void gotoPage(String address,
                   HttpServletRequest req,
                   HttpServletResponse resp)
         throws ServletException, java.io.IOException {
         RequestDispatcher dispatcher =
              getServletContext().getRequestDispatcher(address);
         dispatcher.forward(req,resp);
    So that if a user selects a certain radio button, the servlet will go to another servlet to process the form..this is the IF statement part:
    //forward to another servlet if Full Internet Access requ'd
    String fullint = req.getParameter("FullInternetAcc");
    if (fullint.equals("Add")) {
         gotoPage ("/newuserInternetAccess.java", req, resp);
    When i compile, i get 2 errors:
    1) newuserInternetAccess1.java:404: Class RequestDispatcher not found in type declaration
    RequestDispatcher dispatcher =
    2) newuserInternetAccess1.java:405: Method getRequestDispatcher(java.lang.String
    ) not found in interface javax.servlet.ServletContext.
    getServletContext().getRequestDispatcher(address);
    Does this mean I am using a version of Java that doesn't support this?
    I don't know what to do next, I'm a relative newbie to this stuff.
    THANKS!!!

    String path="";
    if(radio1)
         path="page1.html";
    else if(radio2)
         path="page2.html";
    else
         path="index.html";
    request.getRequestDispatcher(path).forward(request,response);Cheers,
    Anthony

  • Compiler error - why is it still private when i declared it as public?

    import java.io.*;
    import java.util.*;
    public class Flight {
    static private int counter = 1;
         public String da, aa, flight_info, flight_stuff;
         public String st, et, h_et;
         public double price;
    public String taginf;
    public static String stand_t = "", h, m, a_or_p, m_t;
    public static String cMil, stand_h;
    public static String hs, ms;
    public static int hrs, mins, h_mil, m_mil, mil_time;
    public int compare, mt, ht, m_et;
    public int id;
         public void smaller(String dc, double pr)
         double pc;
         Object [] f_ra = flights.toArray();
         for (int i = 0; i < f_ra.length; i++)
         Flight fl = (Flight)f_ra;
              if (fl.da == dc)
                   pc = fl.price - Double.parseDouble(pr);
              else pc = pc;
         System.out.println("The old price was " + fl.price + "and the new price is " + pc);

    If you declare something private, it's private.If
    you declare it public, it's public.except for interfaces where members are implicitly
    made public.True.
    I amend my statement to:
    If you declare something private and it
    compiles, it's private. If you declare it public,
    it's public.plus you could declare something with default access modifier in an interface as in public interface Testable
           String car="Mazda";
    }and it would compile and still be implicitly public

  • Why it is giving compilation error

    byte b = 50;
    byte c = 50*2; //giving compilation error
    why????

    It shouldn't give you compilation errors. It compiles
    fine using JDK 1.4Maybe an earlier compiler (one that doesn't bother to actually check the int literals) is griping about a potential loss of precision, would be my only guess...

  • Compile errors for servlet

    Hi,
    I am trying to compile an addToBasket servlet on windows for use with tomcat 5.5. I have compiled this and used it at university using tomcat5.5 and it worked fine but at home it doesnt compile even though all my other servlets compile fine.
    here are the errors i am receiving
    C:\Servlets+JSP\assignment1>javac addToBasket.java
    addToBasket.java:26: not a statement
    ArrayList<String> basketArray; // Team Array is an array
    ^
    addToBasket.java:31: '(' or '[' expected
    basketArray = new ArrayList<String>();
    ^
    addToBasket.java:34: illegal start of expression
    basketArray = (ArrayList<String>)session.getAttribute("mybasket");
    ^
    addToBasket.java:34: ')' expected
    basketArray = (ArrayList<String>)session.getAttribute("mybasket");
    ^
    4 errors
    this is the code in .java file that it wont compile
    String isbn = request.getParameter("isbn");
         HttpSession session = request.getSession();
         ArrayList<String> basketArray; // basketarray is an array
         //Check to see if this is a new session
         if ( session.isNew() ){
         // new session so create a new ArrayList
         basketArray = new ArrayList<String>();
         session.setAttribute("mybasket",basketArray); //add array to session
         }else{
         basketArray = (ArrayList<String>)session.getAttribute("mybasket");
         // add book to the basket
         basketArray.add(isbn); // add book to array
    any ideas why it wont compile? is it a configuration problem on my home tomcat?
    Regards
    Nick

    danik wrote:
    I am using j2sdk1.4.2_16 so i take it thats too old? if so have you or anyone got a link to 1.5 version?Where do you think that you're here?
    Start here to download the JDK: http://java.sun.com

  • Why do I get the JSP compilation error?

    Why do I get the JSP compilation error?
              Envionment:
              AIX,WLS 5.1 sp10,.........
              Thu Jun 07 11:54:41 CDT 2001:<I> <ServletContext-dcms> Generated java
              file: /usr/local/weblogic/test-weblogic/weblogic/myserver/dcms
              web/app/tmp_war/jsp_servlet/_report/_walmart_95_prod_95_proof_95_report.java
              Thu Jun 07 11:54:42 CDT 2001:<E> <ServletContext-dcms> Compilation of
              /usr/local/weblogic/test-weblogic/weblogic/myserver/dcms_web/a
              pp/_tmp_war/jsp_servlet/_report/_walmart_95_prod_95_proof_95_report.java
              failed: Exception in thread "main" java.lang.NoClassDefFoun
              dError: sun/tools/javac/Main
              java.io.IOException: Compiler failed
              executable.exec([Ljava.lang.String;[javac, -classpath,
              /usr/java_dev2/jre/sh/../lib/rt.jar:/usr
              /java_dev2/jre/sh/../lib/i18n.jar:/usr/java_dev2/jre/sh/../classes:./classes/boot:./eval/cloudscape/lib/cloudscape.jar:./anderson_co
              mmon/3rd_party_jars/jt400.jar:/usr/lpp/db2_07_01/java/db2java.zip::./lib/weblogic510sp8boot.jar:./license:./classes:./lib/weblogicau
              x.jar:./myserver/serverclasses:./anderson_common/3rd_party_jars/jt400.jar:/usr/lpp/db2_07_01/java/db2java.zip::./classes/dcms/com.ib
              m.mq.iiop.jar:./classes/dcms/com.ibm.mq.jar:./classes/dcms/com.ibm.mqbind.jar:./classes/dcms/com.ibm.mqjms.jar:./classes/dcms/com_au
              th.jar:./classes/dcms/com_auth_server.jar:./classes/dcms/com_io.jar:./classes/dcms/com_jms.jar:./classes/dcms/com_jndi.jar:./classes
              /dcms/com_system.jar:./classes/dcms/com_system_server.jar:./classes/dcms/com_util.jar:./classes/dcms/dcms_common.jar:./classes/dcms/
              dcms_common_server.jar:./classes/dcms/dcms_dl_render_server.jar:./classes/dcms/dcms_finalresting_server.jar:./classes/dcms/dcms_fulf
              illment.jar:./classes/dcms/dcms_fulfillment_server.jar:./classes/dcms/dcms_fulfillment_walmart_server.jar:./classes/dcms/dcms_lookup
              _server.jar:./classes/dcms/dcms_media_server.jar:./classes/dcms/dcms_order.jar:./classes/dcms/dcms_order_server.jar:./classes/dcms/d
              cms_order_session.jar:./classes/dcms/dcms_product.jar:./classes/dcms/dcms_product_server.jar:./classes/dcms/dcms_render_client.jar:.
              /classes/dcms/dcms_render_server.jar:./classes/dcms/dcms_talent_server.jar:./classes/dcms/dcms_talent.jar:./classes/dcms/dcms_walmar
              t.jar:./classes/dcms/dcms_walmart_server.jar:./classes/dcms/dcms_jms.jar:./classes/dcms/xreport_pro.jar:./classes/dcms/xtools.jar:./
              classes/dcms/jms.jar:./classes/dcms/dcms_sql.jar:./classes/dcms/dcms_product_sql.jar::/usr/local/weblogic/test-weblogic/weblogic/mys
              erver/tmp_deployments/ejbjar-4971.jar:/usr/local/weblogic/test-weblogic/weblogic/lib/persistence/WebLogic_RDBMS.jar:/usr/local/weblo
              gic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4970.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployme
              nts/ejbjar-4969.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4968.jar:/usr/local/weblogic/test-web
              logic/weblogic/myserver/tmp_deployments/ejbjar-4967.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4
              966.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4965.jar:/usr/local/weblogic/test-weblogic/weblog
              ic/myserver/tmp_deployments/ejbjar-4964.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4963.jar:/usr
              /local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4962.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/
              tmp_deployments/ejbjar-4961.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4960.jar:/usr/local/weblo
              gic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4959.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployme
              nts/ejbjar-4958.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4957.jar:/usr/local/weblogic/test-web
              logic/weblogic/myserver/tmp_deployments/ejbjar-4956.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4
              955.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4954.jar:/usr/local/weblogic/test-weblogic/weblog
              ic/myserver/tmp_deployments/ejbjar-4953.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4952.jar:/usr
              /local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4951.jar:/usr/local/weblogic/test-weblogic/weblogic/./myserve
              r/dcms_web/app/WEB-INF/classes:/usr/local/test-weblogic/weblogic/myserver/dcms_web/app/WEB-INF/classes:/usr/local/weblogic/test-webl
              ogic/weblogic/./myserver/dcms_web/app/_tmp_war:/usr/local/weblogic/test-weblogic/weblogic/myserver/dcms_web/app/_tmp_war,
              -d, /usr/l
              ocal/weblogic/test-weblogic/weblogic/myserver/dcms_web/app/_tmp_war,
              /usr/local/weblogic/test-weblogic/weblogic/myserver/dcms_web/ap
              p/_tmp_war/jsp_servlet/_report/_walmart_95_prod_95_proof_95_report.java])
              at
              weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvoker.java:396)
              at
              weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:202)
              at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:284)
              at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:174)
              at
              weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:164)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:99)
              at
              weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java(Compiled
              Code))
              at com.web.CommonWebUtils.forward(CommonWebUtils.java(Compiled
              Code))
              at com.web.PageNavServlet.service(PageNavServlet.java:76)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:105)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:742)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:686)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:247)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              ----------------------Caught exception while forwarding to page
              /report/walmart_prod_proof_report.jsp------------------------
              ----------------------Exception java.io.IOException: Compiler failed
              executable.exec([Ljava.lang.String;[javac, -classpath, /usr/jav
              a_dev2/jre/sh/../lib/rt.jar:/usr/java_dev2/jre/sh/../lib/i18n.jar:/usr/java_dev2/jre/sh/../classes:./classes/boot:./eval/cloudscape/
              lib/cloudscape.jar:./anderson_common/3rd_party_jars/jt400.jar:/usr/lpp/db2_07_01/java/db2java.zip::./lib/weblogic510sp8boot.jar:./li
              cense:./classes:./lib/weblogicaux.jar:./myserver/serverclasses:./anderson_common/3rd_party_jars/jt400.jar:/usr/lpp/db2_07_01/java/db
              2java.zip::./classes/dcms/com.ibm.mq.iiop.jar:./classes/dcms/com.ibm.mq.jar:./classes/dcms/com.ibm.mqbind.jar:./classes/dcms/com.ibm
              .mqjms.jar:./classes/dcms/com_auth.jar:./classes/dcms/com_auth_server.jar:./classes/dcms/com_io.jar:./classes/dcms/com_jms.jar:./cla
              sses/dcms/com_jndi.jar:./classes/dcms/com_system.jar:./classes/dcms/com_system_server.jar:./classes/dcms/com_util.jar:./classes/dcms
              /dcms_common.jar:./classes/dcms/dcms_common_server.jar:./classes/dcms/dcms_dl_render_server.jar:./classes/dcms/dcms_finalresting_ser
              ver.jar:./classes/dcms/dcms_fulfillment.jar:./classes/dcms/dcms_fulfillment_server.jar:./classes/dcms/dcms_fulfillment_walmart_serve
              r.jar:./classes/dcms/dcms_lookup_server.jar:./classes/dcms/dcms_med
              rder_server.jar:./classes/dcms/dcms_order_session.jar:./classes/dcm
              es/dcms/dcms_render_client.jar:./classes/dcms/dcms_render_server.jar:./classes/dcms/dcms_talent_server.jar:./classes/dcms/dcms_talen
              t.jar:./classes/dcms/dcms_walmart.jar:./classes/dcms/dcms_walmart_server.jar:./classes/dcms/dcms_jms.jar:./classes/dcms/xreport_pro.
              jar:./classes/dcms/xtools.jar:./classes/dcms/jms.jar:./classes/dcms/dcms_sql.jar:./classes/dcms/dcms_product_sql.jar::/usr/local/web
              logic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4971.jar:/usr/local/weblogic/test-weblogic/weblogic/lib/persistence/Web
              Logic_RDBMS.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4970.jar:/usr/local/weblogic/test-weblogi
              c/weblogic/myserver/tmp_deployments/ejbjar-4969.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4968.
              jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4967.jar:/usr/local/weblogic/test-weblogic/weblogic/m
              yserver/tmp_deployments/ejbjar-4966.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4965.jar:/usr/loc
              al/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4964.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_
              deployments/ejbjar-4963.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4962.jar:/usr/local/weblogic/
              test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4961.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/
              ejbjar-4960.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4959.jar:/usr/local/weblogic/test-weblogi
              c/weblogic/myserver/tmp_deployments/ejbjar-4958.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4957.
              jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4956.jar:/usr/local/weblogic/test-weblogic/weblogic/m
              yserver/tmp_deployments/ejbjar-4955.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4954.jar:/usr/loc
              al/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4953.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_
              deployments/ejbjar-4952.jar:/usr/local/weblogic/test-weblogic/weblogic/myserver/tmp_deployments/ejbjar-4951.jar:/usr/local/weblogic/
              test-weblogic/weblogic/./myserver/dcms_web/app/WEB-INF/classes:/usr/local/test-weblogic/weblogic/myserver/dcms_web/app/WEB-INF/class
              es:/usr/local/weblogic/test-weblogic/weblogic/./myserver/dcms_web/app/_tmp_war:/usr/local/weblogic/test-weblogic/weblogic/myserver/d
              cms_web/app/_tmp_war, -d,
              /usr/local/weblogic/test-weblogic/weblogic/myserver/dcms_web/app/_tmp_war,
              /usr/local/weblogic/test-weblog
              ic/weblogic/myserver/dcms_web/app/_tmp_war/jsp_servlet/_report/_walmart_95_prod_95_proof_95_report.java])------------------------
              

    Hi, im getting the same thing,
    Been tryin to download it for days but keeps saying "Invalid signature"
    I even went into ADD REMOVE PROGRAMS hit Apple software update and change and then repair but this did not work.
    Help much appreciated.  Thanks

  • Why no compile  error in this code ?

    strings are immutable... we can not alter it... so why the below does not create compile error ? it is an attempt to alter the string.
    class test
    public static void main(String args[])
        String s1 = new String("amit");
        s1.concat("Poddar");    // why no error ?
        System.out.println(s1);
    }

    strings are immutable... we can not alter it... so
    why the below does not create compile error ? First of all, Strings are immuatable because the String class is coded that way - there willnever be a compiler error to stop you from altering a String's value (which is actually possible via reflection). This is similar to you writing your own class that has a private field and not providing any methods that can alter the field's value. Your new class would be considered immutable in the same way that Strings are considered immutable, and nobody can even attempt (except reflectively), to "alter" an instance of it, so there will never be a compiler error that is due to such an attempt.
    it is an attempt to alter the string.No it isn't. The following is a quote from the Javadoc for String.concat:
    "If the length of the argument string is 0, then this String object is returned. Otherwise, a new String object is created, representing a character sequence that is the concatenation of the character sequence represented by this String object and the character sequence represented by the argument string."

  • Class javax.servlet.jsp.PageContext compilation error

    During Rebuild/compilation of the JSP files inside JDeveloper, I am encountering the compilation error "Error(548,78): method handlepageException (java.lang.Throwable) not found in class javax.servlet.jsp.PageContext. When I developed the same application under IBM WSAD, I included the library com.ibm.servlet.jar and will take care of it. Which Oracle Jdeveloper lib I need to include? Since it is a servlet library error, I tried to include the Oracle "Servlet APIC Classes" but it didn't fix the problem. Thanks in advance!

    hmmm... i had a look and it seems that what you are trying to "import" is actually in a package... instead of import try:
    package javax.servlet.jsp;you may need to go download this "package" and complile it in the directory you are working in.
    my advice: try the above statement (which does compile for me), if it doesn't work, you will need to find the source code for this package and compile it just like you do any other source code.
    hope this helps.

  • Why not compile error on "incompatible interface cast"?

    simeple code here
    class IncompInterfaceTest {
    void doTest() {
    ClassB b = new ClassB();
    InterfaceA a = (InterfaceA)b;
    interface InterfaceA{}
    class ClassB{}
    javac issues "ClassCastException" on runtime rather than compile
    error.
    as i know incompatible type casting may be caught at runtime and
    compiler shows the error.
    but why compiler doesn't do it's job for interfaces? it's just so
    clear to be compile error to me.
    ps. in a case ClassB is final class, compiler issues a error.
    (a thread I started in google groups)
    http://groups.google.co.kr/group/comp.lang.java.programmer/browse_thread/thread/c9c12a8864672436?hl=ko#

    sun9h0st wrote:
    thanks for reply.
    I think i might know something wrong about class, object concept, so I wish you tell me more about it.
    As I though the code below means
    ClassB b = new ClassC();'b' can be an Object of ClassB as a subclass of ClassC.
    'b' IS an Object of ClassC.b is not an object.
    b is a variable that can point to an instance of ClassB or to an instance of any subclass of ClassB.
    >
    so
    b instanceof ClassB == true // as it can be
    b instanceof ClassC == true // as it is
    If b is not null, the first line will always be true.
    If b points to a ClassC or a subclass, the second one will be true.
    It means actual Object(something behind 'b' pointing, i don't know what i call it) is from ClassC to me. (somewhat like c pointer,
    'b' is a bowl that called Object and actuall instance is refered by 'b')No idea what you're saying here.
    if b IS an Object of ClassB
    shouldn't "b instanceof ClassC" is false?If we have C extends B, then...
    B b1 = new B();
    B b2 = new C();
    b1 instanceof B // true
    b1 instanceof C // false
    b2 instanceof B // true
    b2 instanceof C // true
    I Think compiler should be known that instance 'b' hold. No, it doesn't, and it's good that it doesn't, as it keeps the language simpler and more consistent.
    Also, b doesn't hold an instance. It holds a reference to an instance.

  • Why dont we get a compilation error for converting a collection into array?

    Why don't we get a compilation error but get a runtime error while explicit casting of Object[] into a String[]?
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Map;
    public class SampleMap {
      public static void main(String[] args) {
        Map<Integer, String> temp = new HashMap<Integer, String>();
        temp.put(new Integer(1), "cat");
        temp.put(new Integer(2), "rat");
        Collection coll = temp.values();
        String[] arr = (String[]) coll.toArray();
        System.out.println(arr.length);
    } Thanks,
    Harish Srinivasan

    Infiniti wrote:
    Why don't we get a compilation error but get a runtime error while explicit casting of Object[] into a String[]?
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Map;
    public class SampleMap {
    public static void main(String[] args) {
    Map<Integer, String> temp = new HashMap<Integer, String>();
    temp.put(new Integer(1), "cat");
    temp.put(new Integer(2), "rat");
    Collection coll = temp.values();
    String[] arr = (String[]) coll.toArray();
    System.out.println(arr.length);
    } Thanks,
    Harish SrinivasanAn explicit cast's job is to tell the compiler that even though it cannot guarantee that the conversion will work, allow the code anyway and let the runtime handle an error if it occurs.

  • Why no compiler error is generated ?

    When I try to store value 0xff in a byte variale with the statement :
    byte b=0xff;
    a compiler error is generated
    but when I try to store the value 0xffffffff in b no complier error occurs.
    The quetion is if the compiler can truncate bits in case of value 0xffffffff then why not in case of 0xff.

    sharmaneha wrote:
    but the question is why does not the compiler truncate the value for 0xff?That's 255, which is more than 127, which is the max value for a byte (they can be between -128 and 127)

  • Why compilation error--when trying to access the table from itcsi schema

    Hi,
    when querying the table from itcsi.app iam able to see the data but used in proc saying invalid table name. Whats the problem
    when declared p_app_i_old app.app_i%type----It is throwing pls-00201 error
    1 Create or replace procedure Test_insert(p_app_i_old integer,
    2 p_app_i_new integer,
    3 p_APP_ISAC_CPT_I varchar2)
    4 is
    5 cursor c1 is
    6 select distinct table_name,owner
    7 from all_tab_columns
    8 where owner = 'ITCSI' and column_name='APP_I';
    9 t_tablename varchar2(25);
    10 t_string varchar2(300);
    11 t_num number;
    12 Begin
    13 For c2 in c1 loop
    14 t_num := 0;
    15 t_string := 'SELECT count(*) FROM ' || c2.owner ||'.'||c2.table_name||' WHERE APP_I = '||p_
    16 execute immediate t_string into t_num;
    17 if t_num > 0 then
    18 -- dbms_output.put_line('The table name is '||c1_rec.table_name);
    19 if c2.Table_name = 'APP' Then
    20 INSERT INTO itcsi.App
    21 SELECT p_app_i_new,
    22 app_acrnym_c,
    23 app_x,
    24 app_desc_t,
    25 app_ipads_t,
    26 app_prdcn_stat_t,
    27 app_prdcn_stat_d,
    28 app_isd_tier_c,
    29 app_bus_cont_c,
    30 app_extnl_cstm_c,
    31 app-ecrpt_lvl_c,
    32 app_isac_cpt_i,
    33 dsw_gpn_i,
    34 ed_cntnt_srce_t,
    35 usr_upd_uunm_i,
    36 ed_upd_m
    37 FROM itcsi.APP
    38 WHERE app_i = p_app_i_old;
    39 elsif c2.Table_name = 'APP_CETRN' Then
    40 Insert into itcsi.APP_CETRN
    41 select p_app_i_new,
    42 app_cetrn_i,
    43 app-curr_cmplnc_t,
    44 app_rqr_cmplnc_t,
    45 dsw_gpn_i,
    46 ed_cntnt_srce_t,
    47 usr_upd_uunm_i,
    48 ed_upd_m
    49 FROM itcsi.APP_CETRN
    50 WHERE app_i = p_app_i_old;
    51 elsif c2.Table_name = 'APP_GPC' Then
    52 Insert into itcsi.APP_GPC
    53 select p_app_i_new,
    54 gpc_dpnt_x,
    55 gpc_elemy_x,
    56 pro_i,
    57 dsw_gpn_i,
    58 ed_cntnt_srce_t,
    59 usr_usr_upd_uunm
    60 FROM itcsi.APP_GPC
    61 WHERE app_i = p_app_i_old;
    62 End if;
    63 End if;
    64 End loop;
    65 --Commit;
    66* End;
    SQL> /
    Warning: Procedure created with compilation errors.
    SQL> show errors
    Errors for PROCEDURE TEST_INSERT:
    LINE/COL ERROR
    20/2 PL/SQL: SQL Statement ignored
    37/23 PL/SQL: ORA-00942: table or view does not exist
    40/2 PL/SQL: SQL Statement ignored
    Thanks

    how do i check the grant?
    if am in my own schema,how do i connect to itcsi
    schema?if you are using a schema other than the ITCSI schema, you need to login as ITCSI. or if you have dba user account you can grant a privilege of
      GRANT ALL on ITCSI.APPS to <other SCHEMA>;

  • Why does plsql give compilation error for select statement?

    When I run following plsql program, it gives compilation error. Could somebody please point me out what could be wrong here? I am running it from system user.
    create or replace procedure drop_user_proc (iname in varchar2) is
    uname varchar2(100);
    begin
    select username into uname from dba_users where username = upper(iname);
    end drop_user_proc;
    select username from dba_users where username = upper('newuser');
    When I run it, I get following error. dba_users is there that is the reason it works outside plsql block, but it doesn't from inside block.
    SQL> @t4
    Warning: Procedure created with compilation errors.
    USERNAME
    NEWUSER
    SQL> show err
    Errors for PROCEDURE DROP_USER_PROC:
    LINE/COL ERROR
    4/3 PL/SQL: SQL Statement ignored
    4/35 PL/SQL: ORA-00942: table or view does not exist

    Role based grants are not available within the stored procedures.
    Only explicit grants are recognized when compiling stored code.
    You need to grant select on that table to the user where you are creating this procedure.

Maybe you are looking for