Create Classes In Different Packages With Error-free Importing

Hello,
I'd like to create a class which inherits from another class from some other package. So I use "import" keyword to involve the class to build my new class on. However, I hope my new class can be in its own package which is different with one the base class is in. To make it clear, please see the example below:
There are two folders, with name c08 and c09 respectively, in C:\Java which I created for this case. I set the environment variable as C:\Java. There is no problem. Then I saved file "Inter.java" in C:\Java\c08. It's source code is as below:
package c08;
public interface Inter {
     void play ();
     void action ();
And another "Test.java" is saved in C:\Java\c09. Source code as below:
package c09;
import c08.*;
public class Test {
protected class PC implements Inter {
          public void play () {
               System.out.println("Play()");
          public void action () {
               System.out.println("Action()");
It was successfully compiled for "Inter.java". But when comes to "Test.java", it failed with error message of something like "Cannot find the interface Inter". I tried some other ways and I didn't get any results.
I hope to create a class using classes from some other packages while keeping the new one in a different package. How can this be done? (I am currently doing this in J2SE 1.4.01 under Windows XP Home Edition)
Thank you!
Best Regards
Felix

I copied and pasted your code as well as made c08 and c09 directories. I had no errors compiling. I am using NT, but it appears that your problem is Classpath related. You can try to CD to the C:\Java directory and compile using "javac c09\Test.java" That's the command I used.

Similar Messages

  • Accessing a dll from classes in different packages

    Hello java community,
    I am new to Java and especially the jni so your help is greatly appreciated.
    I am having trouble accessing a Windows native dll from classes in different packages. I placed the .dll in my ClassPath. I am able to loadLibrary successfully from class X in my 'common' package. However, when I try to access the same .dll from another class Y in package 'notsocommon'. I get an unsatisfied link error. I changed the X.h file to include common in the function definition (eg. Java_common_X_functionName) and I did the same to the Y.h file (Java_notsocommon_Y_functionName). I am able to work with the dll from the X class but not the Y class. I don't know what I am doing wrong. I am very new to Java, so any help is appreciated.
    Thank you.

    I apologize to everyone for posting this. I figured out my mistake, it was in the dll and not in the java. Also using
    javah -jni notsocommon.Y
    creates the correct header file.

  • Cannot create class in system package while Using Sprite class

    Hi i developed a game using Sprite class & imported
    javax.microedition.lcdui.game.*; package. But when i tried to build this project it gave me "Cannot create class in system package" error. Worst thing is that now again if i build, then it displays error "package javax.microedition.lcdui.game.*; does not exist" . Pls help me

    First exception means that you tried to create a class with the package name equaling one from the predefined libraries in midp/cldc.
    For your second error, add all the jars you are using into the project's classpath.
    Mihai

  • Yet another ALERT: Cannot create class in system package

    I've searched on the forums and seen several postings and none that really explained a solution, just the initial poster replying they fixed the problem. I am new to J2ME and java in general, I'm going off a book and my first test worked fine but this one gives me the the ALERT: Cannot create class in system package, when I select the GO command. The error occurs in the commandAction method where command == go trying to create an alert message. I am using MIDP 2.0 and as I stated new to this whole thing so a detail response would be greatly appreciated and what I need to do to resolve this for now and the future.
    Source code for TextBoxTest.java :
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class TextBoxTest extends MIDlet implements CommandListener
       private TextBox textBox;
       private Alert alert;
       private Command quit;
       private Command go;
       public TextBoxTest()
          // Setup the UI
          textBox = new TextBox("Enter Name", "", 20, TextField.ANY);
          go = new Command("Go", Command.SCREEN, 1);
          quit = new Command("Quit", Command.EXIT, 2);
          textBox.addCommand(go);
          textBox.addCommand(quit);
          textBox.setCommandListener(this);
       protected void startApp() throws MIDletStateChangeException
          Display.getDisplay(this).setCurrent(textBox);
       protected void pauseApp()
       protected void destroyApp(boolean unconditional)
            throws MIDletStateChangeException
       public void commandAction(Command command, Displayable displayable)
          try
             if (command == quit)
                destroyApp(true);
                notifyDestroyed();
             if (command == go)
                alert = new Alert("", "Greetings " + textBox.getString(), null,
    AlertType.CONFIRMATION);
                Display.getDisplay(this).setCurrent(alert);
          catch (MIDletStateChangeException me)
             System.out.println(me + " caught.");
    }

    Ok so my problem isn't with the code it's with the build order. I guess I needed to state that I was following a book and trying to compile and preverify through command line and not using the toolkit or an IDE. So if I use NetBeans 5.0 or the Wireless Toolkit 2.5 I can compile fine.
    So my new question is, can someone show me the steps to build through command line? This is MIDP 2.0.

  • Jsr 180 cannot create class in system package.

    Hi,
    I am trying to run the jsr 180 api sip-example midlets from jbuilder. The project buildes fien but when I run it I get the following:
    C:\JBuilderX\j2mewtk2.0\bin\emulator.exe -Xdevice:DefaultColorPhone -Xdescriptor:"C:\Documents and Settings\aishling\jbproject\aisling\lib\sip-examples.jad"
    Running with storage root DefaultColorPhone
    ALERT: Cannot create class in system package
    Execution completed successfully
    398951 bytecodes executed
    8 thread switches
    434 classes in the system (including system classes)
    2473 dynamic objects allocated (82448 bytes)
    3 garbage collections (58908 bytes collected)
    From going through the archives, I thought I should change the name of the package. So I renamed the directory containing the midlet files from /src/examples to /src/aisexamples and updated each file to include package aisexamples. However this just results in another error (22 + 14) unable to create MIDlet aisexamples.
    Please, please can someone let me know whats going on?
    Thanks,
    Aisling.

    i m also facing the same prob can any body help us

  • Cannot create class in system package

    Hello,
    I wrote a J2ME game for nokia S40 phones. It compiles without any errors, but when I'm trying to run in on the Nokia 7210 phone emulator I receive the following message:
    Cannot create class in system package.
    Howerver running on the Nokia 6230 phone emulator is ok.
    I have obfuscated my applet as I read in previous topics, but still it does not work.
    Can anyone help me?
    Thanks,
    Alexander.

    You get that error when you try to reference a class that is part of the MIDP framework but isn't installed on the phone.
    The 7210 doesn't support MMAPI or WMA or MIDP 2.0, while the 6230 does, so check that you don't have any references (even an import statement), to classes from those packages (like the javax.microedition.media.*, javax.microedition.lcdui.game.*,javax.wireless.messaging.*, etc. packages hierarchies).
    shmoove

  • Create class in java. package

    Not good practice, I know, but is it it possible to do. It seems as the VM (1.3) does not bother about if I set up the RuntimePermissions to be able to access and define Class In Package java.net. I still get a prohibited package name exception.
    Anyone that knows something about it?
    I tried to create a class in java.net with these permissions defined in pollicy file
    permission java.lang.RuntimePermission "defineClassInPackage.java.net";
    permission java.lang.RuntimePermission "accessClassInPackage.java.net";
    //Rickard

    Try loading your classes through the bootstrap java command option (see below).
    Let us know how you fare,
    Manuel Amago.
    Boostrap command line options
    -Xbootclasspath:<directories and zip/jar files separated by ;>
    set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by ;>
    append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by ;>
    I would use the option in the middle.

  • Same class in different package

    I am facing a design decision, I have a set of classes which defined the values of all variables. However, I realized that I need to prepare
    separate set of these classes for different countries (as they may vary), i.e
    my.package.us
         PriceList.java
    my.package.ca
         PriceList.java
    PriceList.java
    ===============
    Public class PriceList {
    public final static Price directFlightPrice = new Price(13500,2); // where 0 is the decimal places
    public final static Price connectFlightPrice = new Price(11000,2); // where 0 is the decimal places
    I am not sure how I can achieve this, would you guys please help? Thank you!

    Isn't this more what you need? You don't want to create a new class, you should create a new instance of a class.
    class PriceList {
        private Price directFlightPrice;
        private Price connectFlightPrice;
        private String country;
        public PriceList(String country, Price directPrice, Price connectPrice) {
            this.country = country;
            directFlightPrice = directPrice;
            connectFlightPrice = connectPrice;
        ... methods to use pricelist variables
    class PriceListTest {
        public static void main(String[] args) {
            Map<String, PriceList> pricesPerCountry = new HashMap<String, PriceList>();
            // This is where you could load data from file and put it into a PriceList object...
            PriceList plUK = new PriceList("UK", new Price(...), new Price(...));
            PriceList plAu = new PriceList("Australia", new Price(...), new Price(...));
            pricesPerCountry.put(plUK.getCountry(), plUK);
            pricesPerCountry.put(plAu.getCountry(), plAu);
            // Use pricelist UK
            PriceList list = pricesPerCountry.get("UK");
    }

  • Moving Bean-class to different package

    Hi,
    For deployment reasons i need the Bean-class in a different package, seperated from package where the Remote and Home are located. I'm not sure how to do this in VisualAge 3.5p2. Simply moving doesn't work.
    Hope someone can help,
    Maarten

    It sounds a little bit strange. Do you want them in packages with different names, like you have bean-class in com.mycompany.project1.mybeanclasses and have the Remote and Home classes in com.mycompany.project2.myremotehomeclasses? It seems possible if you right-click the class you want to move and select 'move', you can move it to a new package. This will be able to separate them.
    Just curious, I think VAJ is very powerful concerning deploying EJBs already so what kind situation makes you want to separate the bean-class and interfaces?
    PC

  • How can I troubleshoot an SSIS package with errors ?

    I am testing a package which is a straightforward move from Oracle table-A  to Oracle table-B 
    I have the header and table tables working fine, but the detail table is getting an error, with the errors not being helpful at all. The detail data flow has around 300+ columns, but the error doesn't say anything that points to the specific error. I
    did review the warnings and found two columns that I needed to substring to be able to fit into the destination.  But still getting an error.
    A colleague said the error "The "input "OLE DB Destination Input" (4781)"
     means this is for Column 4781 - but how do I find that ? We looked in Advanced Settings but the column ID's are all above 5000.
    So how do I troubleshoot this ? In SSIS, I can only think to un-map 1/2 the columns, see if that works, then narrow it down from  there.  I can try to replicate the insert statement in Oracle but that's crazy, imo.
    Here are the errors:
    Error: 0xC0202009 at Load Detail Data, Caremark CET Claims Destination [4768]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x00040EDA.
    An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x00040EDA Description: "Multiple-step operation completed with one or more errors. Check each status value.".
    Error: 0xC0209029 at Load Detail Data, Caremark CET Claims Destination [4768]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "OLE DB Destination Input" (4781)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (4781)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
    Error: 0xC0047022 at Load Detail Data, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Caremark CET Claims Destination" (4768) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (4781). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
    Error: 0xC02020C4 at Load Detail Data, Argus PCT Claiims Source [5281]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
    Error: 0xC0047038 at Load Detail Data, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Argus PCT Claiims Source" (5281) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

    I figured out the error outside of SSIS, by trying to insert the data directly in Oracle ("insert into [my_dest_table select * from [my_source_table"), and that showed me the error (trying to insert varchar-2 into varchar-1). so I corrected and got my package
    working.
    Basic takeaway is the error messages don't tell you anything. It seems like the Oracle error would be readable by Sql Server/SSIS and so it would write that in the log.
    So I basically did your "1>" suggestion and that worked.
    I would like to do "3>" but don't know how . . . if you can point me in the right direction I could probably figure it out, I have a couple of books and I have colleagues whom I can ask.
    thanks !

  • Executing another class from another package with a click of a button

    package language;
    textfield_4 = new JTextField();
    getContentPane().add(textfield_4);
    button_10 = new JButton("Open");
        getContentPane().add(button_10);
        button_10.addActionListener(new java.awt.event.ActionListener()
          public void actionPerformed(ActionEvent e)
            String cmd = "notepad.exe";
            String path = textfield_4.getText();
            try
              Runtime.getRuntime().exec(cmd + " \"" + path + "\"");
            catch (IOException ex)
              ex.printStackTrace();
        button_12 = new JButton("Run");
        getContentPane().add(button_12);From the codes above, what i intended to do is when clicking the "Run" button, it will pass the values from textfield_4 to another class in another package thus, executing the class with the value of textfield_4. What are the steps to do that? If possible, please insert sample codes. Thank you.

    import  anyPackage.AnotherClass;
    button_12.addActionListener(new ActionListener() {
      AnotherClass ac = new AnotherClass();
      ac.execute(textfield_4.getText());
    });Is that what you wanted?

  • How to find packages with errors?

    I have this problem:
    When I compile all invalid packages, I get an error message saying there is one package with some errors. How can I find out which one is it? There is no red cross on any of the package displayed in the package tree.
    Thanks for help

    Hi, after some time I would like to go back to this issue...
    Last week I got this problem again, so I started to look for the problem.
    The thing is we are using multiple schemes and I compiled by accident one of the package bodies to wrong scheme. So there is an invalid package body without its specification... SQL Developer doesn't display such body, maybe because it always supposes there is some spec. This is another disadvantage of the tree structure you are using - package body should be on the same level as package spec!
    Currently if you do such mistake like I did, and use the Compile invalid packages feature, you get an error message about package containing errors and it's hard to find what is going on.

  • Moving Model Class to different package

    Hi,
    How can i move the model class to a different package in CE 7.1
    Regards,
    Senthil

    Hi Senthil
    I thinks this should be possible to realize on the file system level.
    - Find the folder where your model as well as the model classes are located.
    - Search for all files (.) that contain the model class name. Typically it'll find (*.wdmodel and *.wdmodellclass). Change manually the package name within/near the found lines.
    But why do you need to change the model class package separately from the model package?
    BR, Siarhei

  • Dear All, I am running Creat Autoadjustments, but program ends with error.

    Your kind help will be appreciated...
    Oracle Receivables: Version : 11.5.0 - Development
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    ARXAAP module: AutoAdjustment
    Current system time is 26-JUL-2012 09:44:17
    Starting ARXAAP program
    entering main
    Current system time is 26-JUL-2012 09:44:17
    Invoice Currency: BHD
    Remaining Amount: 0 500
    Remaining %:
    Due Date:
    Invoice Type:
    Customer Name:
    Customer Number: 043 043
    Option: 0
    Adjustment Type: CHARGES
    Activity: 1062
    GL Date: 2012/02/29 00:00:00
    Adjust Related Invoices: N
    Reason Code: CHARGES
    validating gl_date
    out of validating gl_date
    Start of log messages from FND_FILE
    End of log messages from FND_FILE
    Executing request completion options...
    Finished executing request completion options.
    AR-ARXAAP: ERROR from afpoget - Terminating Program
    Concurrent request completed
    Current system time is 26-JUL-2012 09:44:17
    Edited by: Ramesh Ippili on 25/07/2012 11:42 م
    Edited by: Ramesh Ippili on 25/07/2012 11:42 م

    Please refer MOS note: Autoadjustment Process Fails With An ERROR From AFPOGET [ID 142549.1]
    to fix this issue.
    regards,

  • Same class name, different packages

    Let's say I have two classes called Team, and each are in their own package. I go to import a.Team and b.Team, what do I have to do to make this work?

    Import them both if you need them both. When you go to use them, refer to them by their fully qualified name.a.Team aTeam = new a.Team();
    bTeam bTeam = new b.Team();You don't really need the import statements from a programatic point of view, but it helps make your code more legible to other developers.

Maybe you are looking for

  • Agent Determination Rule using Function Module

    Hi all, I am trying to create a custom agent determination rule using function module. But my rule is not getting invoked when the workflow is executed. I created a custom rule and linked my function module (with proper signature). FUNCTION 'ZRULEXXX

  • Drag and Drop in Captivate 6

    Hi, I have a Corporate licenced version of Captivate 6. I would like to know how to use the Drag and Drop interaction. Thanking you. With regards Leena

  • IPhoto 11 - Problem viewing shared photos

    Hi, We have two MBP and we're having trouble viewing the photos from the other library via the Share function. The share is occurring through FW. Both MBP are running iPhoto 9.1.3. The issue is that MBP A can see MBP B's photos through share, but MBP

  • Regarding query or code to get Bios Boot Order list display in windows

    hi , I wAnyone can help me that i want to display bios boot order list in windows system  without going to Bios Setup.So is there any query or command to get boot order list in windows system  which is applicable to any company like hp,compaq,dell,le

  • Error in "Create iPod or iPhone version" take 2

    Apologies: an unfinished version of this question was inadvertently posted a few minutes ago. A slip of the finger. Again, sorry. In the Advanced pull-down menu, there is an option, "Create iPod or iPhone version," presumably for making video on the