Help compiling a package

Hello Java peeps, I have been having troubles compiling a package in Java...
My school assessment project was pretty big so I decided to cut into multiple java classes, but instead of having unclean code, I decided to add them all to one package, so i dont have to reference methods with their full names.. except now It doesnt wanna compile correctly...
Lets say I had the following:
ClassA:
package MyPackage;
public class ClassA {
SayHello() {}
ClassB:
package MyPackage;
public class ClassB {
RequestHello() {
SayHello();
The compiler will give me errors that it cant SayHello(). Why is this so?
I tried playing around with my ClassPath, the above classes are in this directory:
C:\Programming\Java\School\*.java
And its compiling as a package, ClassA goes into:
C:\Programming\Java\School\MyPackage\ClassA.class
I have set my classpath to both:
C:\Programming\Java\School\
C:\Programming\Java\School\MyPackage\
Can anyone please help me? Thanks a lot :)

Not only do your methods not have return types, but your call to SayHello() from ClassB is also incorrect. Even if the methods were defined correctly, the compiler would still not find SayHello() because it is looking for it in ClassB.
Putting them in the same package does not give you direct access. You still need to reference ClassA to get access to SayHello(). You just don't need to give it the full package name when referencing ClassA.
e.g.,
ClassA a = new ClassA();
a.SayHello();

Similar Messages

  • Help required in compilation of package body.....

    Hi ..
    While taking the export i encounter the error message..
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    EXP-00056: ORACLE error 6550 encountered
    ORA-06550: line 1, column 26:
    PLS-00201: identifier 'XDB.DBMS_XDBUTIL_INT' must be declared
    ORA-06550: line 1, column 14:
    PL/SQL: Statement ignored
    EXP-00056: ORACLE error 6550 encountered
    ORA-06550: line 1, column 26:
    PLS-00201: identifier 'XDB.DBMS_XDBUTIL_INT' must be declared
    ORA-06550: line 1, column 14:
    PL/SQL: Statement ignored
    EXP-00000: Export terminated unsuccessfully..
    SELECT status,object_id,object_type,owner,object_name
    FROM dba_objects
    WHERE object_name = 'DBMS_XDBUTIL_INT';
    gives the output as...
    status object type owner object_name
    valid synonym public DBMS_XDBUTIL_INT
    valid package xdb DBMS_XDBUTIL_INT
    invalid package body xdb DBMS_XDBUTIL_INT
    when i try to compile the invalid object...
    SQL> alter package XDB.DBMS_XDBUTIL_INT COMPILE BODY;
    Warning: Package Body altered with compilation errors.
    SQL> sho err
    Errors for PACKAGE BODY XDB.DBMS_XDBUTIL_INT:
    LINE/COL ERROR
    61/7 PL/SQL: Statement ignored
    61/17 PLS-00306: wrong number or types of arguments in call to
    'IS_HIERARCHY_ENABLED_INTERNAL'
    74/7 PL/SQL: Statement ignored
    74/29 PLS-00302: component 'GENERATE_TRGNM' must be declared
    108/9 PL/SQL: Statement ignored
    108/37 PLS-00302: component 'TRUNCATE_NAME' must be declared
    123/7 PLS-00201: identifier 'SYS.DBMS_SYS_SQL' must be declared
    123/7 PL/SQL: Statement ignored
    135/9 PL/SQL: Statement ignored
    LINE/COL ERROR
    135/37 PLS-00302: component 'TRUNCATE_NAME' must be declared
    153/9 PL/SQL: Statement ignored
    153/33 PLS-00302: component 'TRUNCATE_NAME' must be declared
    168/7 PLS-00201: identifier 'SYS.DBMS_SYS_SQL' must be declared
    168/7 PL/SQL: Statement ignored
    181/9 PL/SQL: Statement ignored
    181/33 PLS-00302: component 'TRUNCATE_NAME' must be declared
    Since the code is wrapped .. i cant do anything.. needs ur help.
    sorry for explaining in such a detail...
    Message was edited by:
    437022

    Hi,
    In side the Package Body,
    a) invalid arguments for IS_HIERARCHY_ENABLED_INTERNAL
    b) invalid components GENERATE_TRGNM, etc.
    First, you need to correct the above errors and then
    try to compile the Package Body
    Regards,
    Sailaja

  • Help! ORA-03113 while compiling certain packages!

    Hello everyone
    Recently we migrated our PLSQL code from Oracle 8.1.7.0 to 9.2.0.4.
    While compiling our packages in 9i, we are getting the ORA-03113: end-of-file on communication channel error.
    This happens only when we compile two particular packages.
    And then when we connect again immediately, and recompile the same package, it gets compiled.
    This is only happening for two packages, frequently. All other packages are not giving this error.
    Why could this be happening? Any pointers to this would really help.
    Thanks
    Bob

    ORA-3113 often throws a .TRC file in the USER_DUMP_DEST directory. That might give you a clue.
    Cheers, APC

  • Error While compiling a Package

    Hi,
    When am compiling a package am getting a error like
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01631: max # extents (505) reached in table SYS.IDL_UB2$
    Can you pls any one help in this reg...
    Thanks,
    Adhi...

    if you look into sql.bsq in your oracle_home/rdbms
    directory, table IDL_UB2$ has storage parameter
    extents defined as maxextents.
    check out the parameter of your IDL_UB2$ table.
    By the way what is your oracle version?
    For a long time, modifying the sql.bsq file was
    frowned upon, but there is a section in the Tuning
    guide about modifying this file now.
    Reference chapter 15.
    Jaffar
    Message was edited by:
    The Human FlyBut why do you need to modify the sql.bsq file when this problem can be analyzed by checking the availability of free space in SYSTEM tablespace.
    And what benefit will you get by modifying this file after the database has been already created?
    This file is the seed of the database and I think careful consideration must be taken before even thinking of touching this file. Also you must be fully aware of the aftermath.

  • How to compile all package body using sqlplus ?

    hi all,
    How to compile all package body using sqlplus ?
    Please help.
    Amy

    dbms_utility.compile_schema will compile all the invalid objects in a schema, including the invalid package bodies. If you only want to compile the invalid package bodies, you could write your own dynamic SQL stored procedure to do that using the user_source view, but that's a lot more effort for a very minimal benefit.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Compiling Procedures/Packages/Functions

    I'm fairly new to the arena of compiling Procedures/Packages/Funcitons but I was given the task of updating a development DB with a lot of newly created/updated Objects. I have created a shell script to go through all the new files and create or replace all the new objects in sqlplus. My question is how to compile all the newly created objects and their dependencies correctly? I have been using SQL Developer to verify that everything has compiled but I see that some are marked invalid which I assume is because a dependency was compiled after it. What would be my best way to making sure everything is valid? I hope this makes sense but any help would be appreciated.

    You can use a script like this to build your own sql statement to compile the invalid objects. You can add your own statement for other object types at the end with a union, ie TYPE body.
    You will probably need to run it repeated until all objects are VALID. You can put it in a PL/SQL block with a loop and execute immediate so reduce the manual work.
    --PACKAGE
    select 'alter package ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'PACKAGE'
    union
    -- PACKAGE BODY
    select 'alter package ' || object_name || ' compile body;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'PACKAGE BODY'
    union
    --PROCEDURE
    select 'alter procedure ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'PROCEDURE'
    union
    --FUNCTION
    select 'alter function ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'FUNCTION'
    union
    --TRIGGER
    select 'alter trigger ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'TRIGGER'
    union
    --VIEW
    select 'alter view ' || object_name || ' compile;' from user_objects
    WHERE Status = 'INVALID'
    and object_type= 'VIEW'

  • How to compile and package my EJB application

    Hi,
    I just ran the sample programs from the Sun J2EE tutorial. Seems to work fine. I used the ant utility to compile all the programs and the J2EE Deployment Wizard to package and deploy everything. Now how do I compile and deploy a sample EJB program that I have written ?
    I am using the following platforms:
    1: JBuilder 3.0 : IDE (for writing the source code)
    2: JDK 1.4.0_01
    3: J2SDK EE 1.3.1 (EJB/Appln server)
    How do I make ant recognize my program and compile it... i guess the deployment procedure would still be the same.
    Can somebody please help me out on this ??
    Thanks
    prasanna

    Hi,
    Thanks for your prompt reply. I tried that out.. I have a directory called "customer" under which I have my interfaces,bean implementation class and the J2EE application client.
    ANT_HOME is set to : the directory where ant is installed
    JAVA_HOME is set to : the directory where JDK is installed
    J2EE_HOME is set to : the directory where J2EE server is installed
    and PATH : includes the bin directories of JDK, ant and J2SDK EE
    These are the paths I had to set when I ran the J2EE tutorial programs. It worked fine.
    Now when I say : ant myprogram I get an error saying:
    BUILD FAILED
    Target "myprogram" does not exist in this project
    How do I add my program also to the project so that ant can recognize it ?
    Also if there is any other way you can suggest to compile and package my application it would be great...
    Thanks
    prasanna

  • While Compile the Package it shows "alter session set plsql_trace=false"

    Hi,
    My package was working fine and suddenly the status is invalid
    so i tried compiling the package that time sql developer got hanged, package also not getting compiled.
    i asked DBA to find out the status, they said the following query is running from your machine.
    "Alter session set plsql_trace=false". once they kill the session, sql developer got released.
    What could be the reason for this?? please help me to resolve this.......
    Thanks,
    G

    Most "set events" are workarounds or needed for Oracle support to do some debugging. Using them is at your own risk, and probably not supported by Oracle if you get into trouble.

  • Time-out (ORA-4021) while trying to compile a package

    Hi,
    we often get this error when we try to compile a package.
    We have never found a lock on this package nor a user who used it. So we had to restart the database to compile the package
    We have a 9.0.1 database on a Windows system.
    I have seen that this problem has been reported earlier, but I have not seen a solution for this problem.
    Can anyone help us?
    thanks
    Klaus

    Check the V$access view to find what are the objects getting accessed and by whom? And check for users who is accessing that package and the objects which you used in that package. There is a likely chance that if the users are compiling the packages in debug mode from TOAD.. the locks will not released automatically due to a bug in toad version..
    Message was edited by:
    vamski

  • How do I compile a package?

    JAVA QUESTION: When I compile a package do I execute this with javac (the name of the package).java or what?

    Greetings,
    I have a question that relates here... I have been trying to compile a program that uses several packages I have created in an IDE by hand. In the IDE they compile fine, or if I leave out the package name/imports and have all the files in the same dir, but if I try it by hand with all the files in their dirs javac complains it can't find them.
    I have the files in individual folders by package, which works with the ide. Dir structure/package names are roughly as so:
    MyProj (package MyProj)
    -gui (package MyProj.gui)
    --blue (package MyProj.gui.blue)
    --green (package MyProj.gui.green)
    -units (package MyProj.units)
    --foot (package MyProj.units.foot)
    etc.
    I have appropriate import's for each package file, and I am trying to compile from the MyProj folder, where the main file is located.
    My guess is that I need to have all the folders of the various packages in the classpath, or they all need to be sent to javac, which seems really clumsy to me, not to mention wrong - see the quote from the Tut below...
    My path and classpath seem to be all right - I can happily compile stuff, just not when they are in packages :( Actually, come to think, I have the classpath listed with '.\' at the end, which I thought would've been sufficient for javac to workout where the other dirs are.
    From Java tut:Managing Source and Class files: "From the top- level directory, the compiler and the interpreter can construct the rest of the path, based on the package and the class name for the class"
    What am I doing wrong, or is my guess correct? Is there any easier way of compiling packages by hand or do I really need an IDE? Having twenty or thirty sources and classes in one dir doesn't really appeal...
    And does anyone know of a good ide in Linux (which more or less sparked this issue), which I am just learning to love...
    Any help is appreciated.
    Cheers

  • Compiling two packages referenced to each other

    I've got two Packages named PackageA and PackageB from other developer
    PackageB imports a class from PackageA as
    import PackageA.class1;
    PackageA imports all classes from PackageB as
    import PackageB.*;
    My questions are:
    1. Is it allowed in Java?
    2. How do I compile these packages? Here is what I tried. I wrote a Ant Script to compile I couldn't compile succefully. Then I tried to compile manually by compiling first Class1 from PackageA, followed by PackageB and then came back to compile remaining classes in PackageA. The compilation was successful. But what I don't understand is how it compiled successfully in the command prompt.
    Any help would be appreciated
    thanks

    Probably the classpath setting wasn't correct, so the "other" class couldn't be found. See How Classes are Found, http://java.sun.com/j2se/1.4.1/docs/tooldocs/findingclasses.html

  • How to get return code of compiling a package

    Hi,
    i want to compile a package and if it was not succesfull to write the error_message from "show errors" into a file.
    thx
    Wolle

    the problem with compiling individual packages is that you might inadvertently invalidate others. you should also programmatically check package dependencies too so you dont break any accidentally.
    if you're only compiling package bodies, this shouldn't be an issue, but if youre also compiling specs, this is something you should keep an eye on.
    i wrote an application that uploads new packages i commit in cvs to our database and then recompiles them. it then reports whether or not compilation was successful. this helps eliminate alot of user error when people manually recompile packages in HA environments. however, i recompile the entire schema when i do this (this is not something run very often). i can get away with this at my shop because the schema is very small, but this might not be a practical solution for everyone.
    this is how i check for dependencies:
    FROM public_dependency pd, user_objects uo
    WHERE referenced_object_id IN (select object_id from user_objects where object_name= UPPER(?))
    AND uo.object_id = pd.object_id
    this is useful for saving a snapshot of current package (in case of reversion):
    SELECT TEXT FROM USER_SOURCE WHERE NAME = ?
    this is how you can recompile the schema:
    DBMS_UTILITY.COMPILE_SCHEMA(?, TRUE, TRUE);
    i do a check for invalid objects in the schema before i even start (And exit with error if any are found) :
    SELECT OBJECT_NAME, STATUS
    FROM USER_OBJECTS
    WHERE (OBJECT_TYPE='PACKAGE' OR OBJECT_TYPE='PACKAGE BODY')
    AND STATUS <> 'VALID'
    Hope this info helps.
    Edited by: user577162 on Aug 25, 2008 2:21 PM

  • Compile UTL_FILE PACKAGE BODY

    Hi ALL,,,
    I refreshed one db from PROD dump.
    After that I compiled all Invalid objects .But am unable to compile UTL_FILE PACKAGE BODY
    Showing all are invalid.
    OBJECT_NAME OBJECT_TYPE OWNER
    UTL_FILE PACKAGE BODY UTLFILE
    UTL_FILE_EX PACKAGE BODY UTLFILE
    UTL_FILE_ADMIN PACKAGE BODY UTLFILE
    SQL> show parameter utl
    NAME TYPE VALUE
    create_stored_outlines string
    utl_file_dir string
    Please help me how to compile this.
    If I tried to copile manualyy..I am gettimg Error like..PACAGE ALTERED WITH COMPILATION Errors.
    Thanks
    Manohar.

    Invalid objects are best compiled by using
    sqlplus / as sysdba
    @?\rdbms\admin\utlrp
    This will report the number of invalid objects when finishing.
    When you still have invalid objects you should query dba_errors where name='<name of invalid object>'
    All Oracle provided sources are in
    %ORACLE_HOME%\rdbms\admin
    You can simply find or grep for utl_file.
    There always will be two files
    utl<facility>.sql (or dbms<facility>.sql) and prvt<facility>.plb
    You need to run them both in sqlplus connected as sysdba.
    Sybrand Bakker
    Senior Oracle DBA

  • Compiling a package without disturbing the load process

    Hi,
    I need to compile a package, with the changes, in the database without stopping the load process that is using this package. Please let me know if any one has any ideas.
    Thanks

    sdk11 wrote:
    Hi,
    I need to compile a package, with the changes, in the database without stopping the load process that is using this package. Please let me know if any one has any ideas.
    ThanksIf you mean: "I need to create or replace a package", while some session is still running code of that package.
    Then sorry: nocando.
    Unless you are on 11.2, in which case you could (with the necessary preparation/configuration done first) create a new version of the package in another edition than the session is using. But the session will have to finish its work using the package as-is currently.

  • Re-compiling a package in a stored procedure

    Hi All,
    We are using Oracle 10g. I have coded a stored procedure that does many things one of which is re-creating a Materialized View using Dynamic SQL. However, when this Materialized View is created, a package that this stored procedure needs, becomes invalid. What is the syntax for recompiling the package using Dynamic SQL? I tried something like script listed below, but I am getting "*ORA-24344: success with compilation error*" error message. I like to re-compile the package before it's use in this stored procedure.
    DECLARE
          v_sql         VARCHAR2 (1000);
          object_name   VARCHAR2 (50) := 'TEST.PS2_FNS366';
    BEGIN
           dbms_output.put_line('This is a test.');
           v_sql := 'Alter package ' || object_name || ' compile  package';
           dbms_output.put_line (v_sql);
           EXECUTE IMMEDIATE v_sql;
           v_sql := 'Alter package ' || object_name || ' compile  body';
           dbms_output.put_line (v_sql);
           EXECUTE IMMEDIATE v_sql;     
    END;Thanks,
    Seyed

    Hi Justin,
    I agree with you. Initially, I didn't want to use materialized view in the stored procedure to load a table, but I a kind of was forced into it. I first tried using an Oracle View, but then the Oracle package using it was not finding the view. Then I tried to grant select to it, that failed too. That is when I decided to use a materialized view because, at least I could issue the needed grants.
    After seeing your e-mail and Frank's, I went back to my original plan. I re-created the old view and then tried to give it the right grants. Here is what I tried and the resulting error message:
    GRANT SELECT ON STUDENT.v_ben_reg_case_number TO SCOTT A grant similar to above results in ORA-01720: grant option does not exit for one of the underlying tables. Our DBA tried granting a developer role a system privilege called under_any_role, but that didn't solve it either.
    Thank you for your assistance,
    Seyed

Maybe you are looking for