Using Packages in Unix

I have many class files that I have been developing in a Windows environment, and I have just recently moved them to a UNIX environment and when I did the package statements are being ignored. When compiling the .java files the .class files are being put in the current directory and not the directory specified by the package statement. I am using jre 1.3.1 environment. Does anyone know why the package statements are not being recongnozed.
Thanks
Shawn

in unix the the first line in your java file should be like
packnix com.acme.myproggy;
So, if you want cross platform, do
#ifdef WIN32
package com.acme.myproggy;
#else
packnix com.acme.myproggy;
#endif
NOTE: it's surprising that sun wouldn't have made this cross platform, as well.
Sorry, but i'm just feeling silly.

Similar Messages

  • How compile and run a project or package in Unix environment?

    I write an application of java package using Jdeveloper tool. The first statement in each program is "package packgename". How can I compile this project or package in Unix command line? If I compile each program in the package, then error msg will show when one program reference another program.

    The first statement in each program is "package packagename".Then your java files must be in a directory called "packagename". Let's say this packagename directory is in your /source/java directory, then when you compiling, you need to do:
    cd /source/java/packagename
    javac -classpath /source/java OneOfYours.java
    and it should then compile.
    --lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How can i call a method from the a subdirectory using packages

    This is my directory structure:
    java
    --p1
    --One.java
    --p2
    --Two.java
    package java.p1;
    import p2.Two;
    public class One
         public static void main(String args[])
              Two obj = new Two();
              obj.p();
    package java.p2;
    public class Two
         public void p()
              System.out.println("p method");
    ERRORS !!
    C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:3: package p2 does not exist
    import p2.Two;
              ^
    C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
    symbol  : class Two
    location: class java.p1.One
              Two obj = new Two();
                    ^
    C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
    symbol  : class Two
    location: class java.p1.One
              Two obj = new Two();
                                  ^Help me out. Thanks.

    jinchuriki123 wrote:
    This is my directory structure:
    java
    --p1
    --One.java
    --p2
    --Two.java
    package java.p1;
    import p2.Two;
    public class One
         public static void main(String args[])
              Two obj = new Two();
              obj.p();
    package java.p2;
    public class Two
         public void p()
              System.out.println("p method");
    ERRORS !!
    C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:3: package p2 does not exist
    import p2.Two;
    ^
    C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
    symbol  : class Two
    location: class java.p1.One
              Two obj = new Two();
    ^
    C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
    symbol  : class Two
    location: class java.p1.One
              Two obj = new Two();
    ^Help me out. Thanks.You don't have a class p2.Two, You do have a class java.p2.Two. Package paths aren't relative.
    Also, it's recommended not to use package names containing "java" or "javax" (or is it illegal to do so?). Change your package & folder names.
    db

  • Using package constant in SQL

    I am trying to use a package constant in a query as follows:
    SELECT field1 FROM table t WHERE CEIL(sysdate - t.field2) > schema.package.constant
    field1 is a name
    field2 is a timestamp
    constant is an integer indicating the expiration time in days
    basically I am trying to find all expired items.
    I get the error "ORA-06553: PLS-221: 'constant' is not a procedure or is undefined" on this query.
    I use this same query as a cursor in the package itself with no errors.

    Unfortunately you cannot directly use package global variables in select statements like this.
    One workaround is to use bind variables for that:
    <p>
    SQL> CREATE OR REPLACE PACKAGE pkg
    AS
       myconstant   VARCHAR (20) := 'This is my constant';
    END pkg;
    Package created.
    SQL> VAR myconstant  VARCHAR2 (20)
    SQL> EXEC :myconstant :=  pkg.myconstant
    PL/SQL procedure successfully completed.
    SQL> SELECT :myconstant
      FROM DUAL
    :MYCONSTANT                                                                    
    This is my constant                                                            

  • Using packaged functions in Apex

    Hi,
    I'm fairly new to apex and I am about to write an app which needs to access a SQL server database. My local dba has set up the transparent gateway and I can select from and update the SQLServer database no problem via a db link. What I need to decide is whether to code the sql for reports etc directly into the apex page or to call a pl/sql function returning a select statement. I would like to have all the code in packages as a lot of it will be used by multiple apps in future but is there any extra overhead in doing this:
    declare
    l_sql varchar2(4000);
    begin
    select package.function into l_sql from dual;
    return l_sql;
    end;
    rather than coding the SQL directly in the page? Also is there a more efficient way of using packaged functions to select data rather that just have it returning sql statements.
    Thanks in advance.
    Dave

    Hi
    I only use function returning select when I have a strong reason to do so, because it is so much more difficult to test and maintain. Not sure about performance, but I think it is not that much worse.
    If you simply want to reuse SELECT statements, you could use views instead.
    Anyway, if you decide to use the package solution, at least you can make it much simpler -- just code like this in the page:
    return package.function;
    I hope this helps.
    Luis

  • Error when using packages

    hi!
    I am new to java .... learning how to use packages. I have created dir on my harddrive c:\learning\java ... in which i have created com\tests.... added c:\learning\java to path env variable .... And have written two java programs.
    1. jmain.java
    adds two integers and puts in another integer
    public int sum()
    2. jtest.java
    main method ... and creates an object of jmain class ... and uses
    jmain jm = jmain();
    jm.sum();
    Both these classes are in the same package com.tests and both jmain.java uses package com.tests;
    and jtest.java uses package com.tests; import com.tests.*;
    3. jmain compiles alright
    but when compiling jtest.java compiler gives an error saying can't resolve symbol
    symbol : jmain.class
    path : com.tests.jtest
    What to do now ???????? when i went to check my directory structure ... i am doing everything right.... using case okay, path is okay, etc
    still running errors .... please suggest a solution.
    thanks.

    I tried this ... it's giving me same error.
    Please help.
    I am on winXp so i added at the end of my path env var .... c:\learning\com\tests
    //jmain.java
    package com.tests;
    public class jmain
    public int x=4;
    public int y=66;
    public int sum = x+ y;
    public printsum ()
    System.out.println(sum);
    //jtest.java
    package com.tests;
    import com.tests.*;
    public class jtest
    public static void main(String [] args)
    jmain jm = jmain();
    jm.printsum();
    Above is my program. Both java files are in C:\learning\com\tests
    And, is there a difference between CLASSPATH and setting environment variable or system variable ???? What is SOURCEPATH too ???
    Please help
    Thanks in advance.

  • Advantages of using Oracle with Unix over Windows server

    Hi there,
    I want some article/document which depicts the advantages of using Oracle with Unix (say HP-UX or Solaris backend). Actually the plan is to use some Data Warehousing applications using Cognos Poweplay, ReportNet and either Decision Stream of Cognos or Oracle Warehouse builder may be used as ETL tool. For Data mining applications we are planning to use SPSS Clementine. The Data volume will be substantial one. At present we are developing some prototype in Windows 2003 advanced environment. We are plaiing to use Risc server and RAID-5. Pl. advice some ideal architecture for us, as you know, it's typically a Govt. level application data (mostly archival data). The reports will be published using Report Net, Adhoc query etc, OLAP analysis will be done using Powerplay.
    Regards,
    Anupam Basu

    Hi there,
    I want some article/document which depicts the advantages of using Oracle with Unix (say HP-UX or Solaris backend). Actually the plan is to use some Data Warehousing applications using Cognos Poweplay, ReportNet and either Decision Stream of Cognos or Oracle Warehouse builder may be used as ETL tool. For Data mining applications we are planning to use SPSS Clementine. The Data volume will be substantial one. At present we are developing some prototype in Windows 2003 advanced environment. We are plaiing to use Risc server and RAID-5. Pl. advice some ideal architecture for us, as you know, it's typically a Govt. level application data (mostly archival data). The reports will be published using Report Net, Adhoc query etc, OLAP analysis will be done using Powerplay.
    Regards,
    Anupam Basu

  • Using utl_file and unix pipes

    Hi,
    I'm trying to use utl_file and unix pipes to communicate with a unix process.
    Basically I want the unix process to read off one pipe and give me back the result on a different pipe.
    In the example below the unix process is a dummy one just copying the input to the output.
    I cant get this to work for a single plsql block writing and reading to/from the pipes - it hangs on the first read of the return pipe.
    Any ideas?
    ======== TEST CASE 1 ===============
    create directory tmp as '/tmp';
    on unix:
    cd /tmp
    mknod outpip p
    mknod inpip p
    cat < inpip > outpip
    drop table res;
    create table res (m varchar2(200));
    declare
    l_filehandle_rec UTL_FILE.file_type;
    l_filehandle_send UTL_FILE.file_type;
    l_char VARCHAR2(200);
    begin
    insert into res values ('starting');commit;
    l_filehandle_send := UTL_FILE.fopen ('TMP', 'inpip', 'A', 32000);
    insert into res values ('opened inpip ');commit;
    l_filehandle_rec := UTL_FILE.fopen ('TMP', 'outpip', 'R', 32000);
    insert into res values ('opened outpip ');commit;
    FOR i in 1..10 LOOP
    utl_file.put_line(l_filehandle_send,'line '||i);
    insert into res values ('written line '||i); commit;
    utl_file.get_line(l_filehandle_rec,l_char);
    insert into res values ('Read '||l_char);commit;
    END LOOP;
    utl_file.fclose(l_filehandle_send);
    utl_file.fclose(l_filehandle_rec);
    END;
    in a different sql session:
    select * from res:
    starting
    opened inpip
    opened outpip
    written line 1
    ============ TEST CASE 2 =================
    However If I use 2 different sql session (not what I want to do...), it works fine:
    1. unix start cat < inpip > outpip
    2. SQL session 1:
    set serveroutput on size 100000
    declare
    l_filehandle UTL_FILE.file_type;
    l_char VARCHAR2(200);
    begin
    l_filehandle := UTL_FILE.fopen ('TMP', 'outpip', 'R', 32000);
    FOR i in 1..10 LOOP
    utl_file.get_line(l_filehandle,l_char);
    dbms_output.put_line('Read '||l_char);
    END LOOP;
    utl_file.fclose(l_filehandle);
    END;
    3. SQL session 2:
    set serveroutput on size 100000
    declare
    l_filehandle UTL_FILE.file_type;
    begin
    l_filehandle := UTL_FILE.fopen ('TMP', 'inpip', 'A', 32000);
    FOR i in 1..10 LOOP
    utl_file.put_line(l_filehandle,'line '||i);
    --utl_lock.sleep(1);
    dbms_output.put_line('written line '||i);
    END LOOP;
    utl_file.fclose(l_filehandle);
    END;
    /

    > it hangs on the first read of the return pipe.
    Correct.
    A pipe is serialised I/O device. One process writes to the pipe. The write is blocked until a read (from another process or thread) is made on that pipe. Only when there is a reader for that data, the writer is unblocked and the actual write I/O occurs.
    The reverse is also true. A read on the pipe is blocked until another process/thread writes data into the pipe.
    Why? A pipe is a memory structure - not a file system file. If the write was not blocked the writer process can writes GBs of data into the pipe before a reader process starts to read that data. This will drastically knock memory consumption and performance.
    Thus the purpose of a pipe is to serve as a serialised blocking mechanism between a reader and a writer - allowing one to write data that is read by the other. With minimal memory overheads as the read must be serviced by a write and a write serviced by a read.
    If you're looking for something different, then you can open a standard file in share mode and write and read from it using two different file handles within the same process. However, the file will obviously have a file system footprint ito space (growing until the writer stops and the reader terminates and trashes the file) .
    OTOH a pipe's footprint is minimal.

  • Using package constants in package SQL - acts as bind variable or literal?

    I'm looking for confirmation on the performance impact of using package constants in package SQL.
    Let's say I have a number of queries in package code that refer to various literals that are prone to typos e.g. "CANCELLED" instead of "CANCELED". To reduce the chances of this happening, I have an APP_GLOBALS package where I declare constants for each literal:
    C_CANCELED CONSTANT VARCHAR2(12) := 'CANCELED';And in queries that refer to literal 'CANCELED' I use APP_GLOBALS.C_CANCELED instead. This way the typo is caught during compilation. For example:
    BEGIN
    --Do something with all 'Canceled' orders
      FOR r IN (SELECT order_id
                  FROM orders
                 WHERE status = APP_GLOBALS.C_CANCELED)
      LOOP
      END LOOP;
    END;Assume that:
    - the STATUS column is indexed
    - the possible values are PENDING, APPROVED, CANCELED
    - a small percentage of orders are CANCELED
    From the optimizer's perspective is the query equivalent to
    SELECT order_id
      FROM orders
    WHERE status = :varor
    SELECT order_id
      FROM orders
    WHERE status = 'CANCELED'?
    According to what I see in v$sqltext_with_newlines, it's the first one. Can anyone suggest an alternative way of replacing literals in package SQL to prevent typos? Worst case, I suppose I can start with constants so that it compiles successfully then do a global replace of the constants with the literals.

    Can anyone suggest an alternative way of replacing literals in package SQL to prevent typos?I cannot think of any. But, here is the thing. If the typos are there, then, it technically is a bug even though both the codes would compile. The bug will be hunted down when the program doesn't work as intended. Wouldn't most typos be caught in unit testing of the code?
    Also, if you replace a string literal with a variable, then, maybe (just maybe, depending on your version of the dbms), it may end up picking a different execution plan. That might be an unintended consequence.

  • Problem using icommand in UNIX

    Hi,
    I'm trying to use icommand in UNIX. I navigate to the middleware home on the server and in the .../BAM/Bin directory I can see an icommand.bat file and the standard icommand file. However, I can't see an icommand.sh file. I've tried some commands out but keep getting the 'file not found' error.
    Can someone please guide me on the instructions for using icommand in UNIX as I can't seem to find anything anywhere?
    Thanks

    Example :
    <OracleHome>/bam/bin/icommand -cmd import -file <filename>

  • How packages A uses packages B, Please?

    Dear All
    I have two packages and like to have the classes in A uses the Classes in B, A and B are seperate packages and each is compsed of many classes. My IDE is NetBeans 4.0, just if that important.
    Please let me know how I can uses Package B classes as easy as importing jar files.
    Cheers, khalid

    ok I will try this, I understand that you mean when
    both packahes a and b ar ein the same directory.Has nothing to do with whether the packages are in the same directory: You always provide the full package name in the import statement. Go through a tutorial or two, carefully. ...\com\mycompany\foo\Bar.class
    ...\com\mycompany\baz\quz\Splort.class
    // For Bar to use Splort:
    package com.mycompany.foo;
    import com.mycompany.baz.qux.Splort;
    public class Bar {}
    // For Splort to use Bar:
    package com.mycompany.baz.qux;
    import com.mycompany.foo.Bar;
    public class Splort {}
    One
    more to ask, What about when many classes in package
    b.You can use import whateverpakcage.*; It's generally considered more maintainable to list individual classes though.
    import a.B;
    import a.C;
    // etc.

  • Using packages breaks batch file

    Hi there, I wonder if anyone can help me here.
    I've been continuing work on somebody else's previous project, and everything is fine except for the batch file used to run the program from non development. I decided to use Eclipse to develop as opposed to the previous JCreator, and Eclipse gave an error unless I used packages, however this breaks the batch file
    Here's the orginal text from the batch file -
    java.exe -Xmx256m -classpath C:\InsTra\JARS\ant.jar;C:\InsTra\JARS\jaxen-core.jar;C:\InsTra\JARS\jaxen-jdom.jar;C:\InsTra\JARS\jdom.jar;C:\InsTra\JARS\saxpath.jar;C:\InsTra\JARS\xalan.jar;C:\InsTra\JARS\xerces.jar;C:\InsTra\JARS\xml-apis.jar;c:\InsTra\code_files InsTra
    The batch file is located in C:\InsTra, the external JARS are in a JARS subfolder, and the java and class files are in Code_files. The main class is InsTra. I get the error NoClassDefFoundError
    I've tried making the last bit Code_files.InsTra in case it needed to reference the package, but I'm new to this I'm afraid so have little experience of this sort of thing.
    Any help is welcome
    Thanks
    Daniel

    Then either your compiled class is not on the classpath, or you have not used the correct class name. Or both.
    The classpath must point to the root of the package hierarchy.
    The class name must include the package name (which is dictated by the package line at the top of your source file).
    The compiled class file must be in the correct directory.
    Given the information that you have provided, your class file should have the following path:
    c:\InsTra\code_files\Code_files\It should also have the following line at the top of the .java file:
    pacakge Code_files;Class names are case sensitive. Remember that the class path points to the root of the package hierarchy, NOT each of the directories containing class files. For example, if your classpath is thus:
    c:\fooYour class file is in:
    c:\foo\foo\Spong.classWith a package of:
    package foo;And you execute it with:
    java -classpath c:\foo foo.SpongThen it will work. The following will not:
    java -classpath c:\ foo.Spong
    java -classpath c:\foo\foo Spong
    java -classpath c:\foo\foo foo.Spong
    java -classpath c:\foo\foo Spong.class
    etc.

  • Updating a JAR that uses packages

    Hi There,
    I have a problem in that I am trying to update a class within a JAR which uses packages. The issue is that when updating the JAR, the class I have requested to update is simply placed in the root of the JAR and not in the required package.
    I need to to this within a Java program, so unpacking and re-packing the JAR is not an option.
    Here is what i've been trying:
    I have a class called UserProfile.class, which resides within my messages package - Structure: /messages/UserProfile.class
    When I call the update command:
    jar uf C:\AdminUI.jar E:\project\code\Eclipse_Proj\messages\UserProfile.class
    It creates the folder structure /project/code/Eclipse_Proj/messages within the JAR file and places UserProfile.class within this folder - when in fact the UserProfile.class should be placed within the /messages folder.
    Any ideas on how I can place the class in the correct folder would be much appreciated.
    Thanks very much
    K
    null

    Thanks for the reply!
    Yeah that works, but i'm trying to update the JAR from a Java program using
    Runtime.getRuntime().exec()
    but when I try to run the command Runtime.getRuntime().exec("cd c:") I get the below exception:
    java.io.IOException: CreateProcess: cd c: error=2
    I understand there is a -C parameter to temporarily change directory so I tried the following command:
    jar uf C:\AdminUI.jar -C E:\project\code\Eclipse_Proj \messages\UserProfile.class
    But this simply inserts the UserProfile.class into a jar under the following directory structure:
    project/code/Eclipse_Proj/messages/UserProfile.class
    Thanks again for your help.
    Any input much appreciated
    K

  • Use of XVFB Unix tool

    we have got a Java application deployed on a WAS 6.40 SP13 and we want to use the server unix tool xvfb for displaying drawings in the browser of the users.
    In a previous step we have got this application running on a IPlanet server and we added these 2 lines:
    DISPLAY=:1.0; export DISPLAY
    /usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
    in the start file of the application of the IPlanet server.
    So my question is: where can i add these lines in a J2EE project developped with SAP Developer Studio to use the tool ?
    Thank in advance,
    Eric.

    Hi
    RWD uPerform records your actions in Microsoft Windows,web-based, and enterprise applications, and outputs a professionally formatted document and simulation. You can capture screens, buttons, edit fields, and more in the target application.
    The recording process captures information to simultaneously produce both a simulation view and a document view of procedural content.
    RWD uPerform captures actions in the following target applications:
    ❐ Standard Microsoft Windows and web browser applications: Support for these
    applications is provided in the uPerform base recorder. Application adherence to
    World Wide Web Consortium (W3C) and Microsoft Windows standards will
    determine the consistency and quality of recording. Due to the technology involved in
    recording, the DOS command window cannot be recorded.
    ❐ SAP: Support for SAP applications is provided in the uPerform SAP plug-in recorder.
    ❐ Oracle: Support for this application is provided in the uPerform Oracle plug-in
    recorder.
    ❐ PeopleSoft: Support for this application is provided in the uPerform PeopleSoft plugin
    recorder.
    ❐ Citrix: In addition, support for applications in the Citrix Presentation Server 4.5
    environment is also available.
    Regards
    Manish Bansal

  • How to prevent downgrading of the app in meta package using package versioning feature of package maker tool?

    Hi,
    Created  an installer i.e, meta package using package maker tool. I want  to prevent downgrading of the application or package on the target/installed volume. 
    Problem is, if there is a newer version of app and when I try to install any older version, then it does not throw any error message to the end user and replaces the existing newer version with the older version of app, which should not happen. But, if I check the package version using version comparison of Package  maker tool, that works fine with flat packages i.e, with the .pkg files. So, I need the solution for metapackages(.mpkg) and want to prevent downgrading of app for metapackages. I am not getting any solutions for this. Can someone guide me on this?
    Thanks for the help provided.
     

    Hi,
    Created  an installer i.e, meta package using package maker tool. I want  to prevent downgrading of the application or package on the target/installed volume. 
    Problem is, if there is a newer version of app and when I try to install any older version, then it does not throw any error message to the end user and replaces the existing newer version with the older version of app, which should not happen. But, if I check the package version using version comparison of Package  maker tool, that works fine with flat packages i.e, with the .pkg files. So, I need the solution for metapackages(.mpkg) and want to prevent downgrading of app for metapackages. I am not getting any solutions for this. Can someone guide me on this?
    Thanks for the help provided.
     

Maybe you are looking for