My question on package .

I am learning package. I create first class 'Box2' and define it in package 'pkg1'.
package pkg1;
class Box2 {
    void Box2() {
         System.out.println("it is box2");
}I then create second class 'Box3' and define it in package 'pkg1'.
package pkg1;
class Box3{
  public static void main(String[] arguments) {
      Box2 b= new Box2();
} Box2.java is compiled successfully, Box3.java failed when compiled with the below error messages:
============================================
h:\java\pkg1\Box3.java:5: cannot resolve symbol
symbol : class Box2
location: class pkg1.Box3
Box2 b= new Box2();
^
h:\java\pkg1\Box3.java:5: cannot resolve symbol
symbol : class Box2
location: class pkg1.Box3
Box2 b= new Box2();
^
2 errors
============================================
Both Box2.java and Box3.java are saved under .\pkg1 folder.
As I understand, if two classes are in the same package, I could use them without 'import'. Could anyone help me to check what is wrong on them?{code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

ij_2005 wrote:
The jdk version is 1.3. I go to c: driver and compile the fils
C:\PROGRA~1\JDK1.3\BIN>javac h:\java\pkg1\Box2.java
C:\PROGRA~1\JDK1.3\BIN>javac -classpath h:\java\pkg1 h:\java\pkg1\Box3.java
This is the files under h:\java\pkg1 folder.
09/04/08 14:07 <DIR> .
09/04/08 14:07 <DIR> ..
09/04/08 13:46 392 Box2.class
09/04/08 13:46 106 Box2.java
09/04/08 13:49 135 Box3.java
3 File(s) 633 bytesThe classpath should point to the root of the package structure, that is, h:\java and not h:\java\pkg1
Kaj

Similar Messages

  • A simple question about packaging

    Hello,
    I have a question related to java package.
    I download a java package from web, suppose the jar file is: fghi.jar, includes classes and source files.
    I copy it to c:\temp\ directory, and then uncompress it onto my C:\temp\ directory.
    Then the directory structure is: c:\temp\com\abcd\fghi\swing
    one of the file under c:\temp\com\abcd\fghi\swing directory is Test.java:
    package com.abcd.fghi.swing;
    public class Test {
    public static void main(String[] args){
    I want to run the test program after compiling it
    c:\temp\com\abcd\fghi\swing\java Test
    Then it gives the error message:
    "Exception in thread "main" java.lang.NoClassDefFoundError"
    By the way, I had modified my CLASSPATH variable,
    CLASSPATH=c:\temp\fghi.jar
    My computer OS is windows 2000.
    Can anyone tell me how I can run it successfully?
    Thank you very much!

    If you didn't change anything in the java program, you don't need to compile them. In order to run the Test java program, change current directory to c:\temp and run following command.
    java com.abcd.fghi.swing.Test

  • Question about packages from AUR that get into [community]

    just noticed that powerpill is out of the AUR and into [community] (yeah!).  My question: since I installed powerpill and its two deps from the AUR, should I uninstall the versions that I built from the AUR then install from the repo or doesn't it matter?  In other words, will pacman know that these are in the repos and if updates are posted, will it fetch them just like any other package?
    I think the answer is no to the uninstall and yes to pacman just working, but I'd like to hear from the pros
    Thanks!

    Thanks for the confirmation.  Powerpill rocks - I'm very glad to see that it's in [community] now.  I took a stab at updating the beginners guide with an entry about it.  I don't have much time tonight to do it justice, but at least it's a start.

  • Basic Questions about Package Installation

    I have one basic question about installing packages.
    How can I find out if needed software is already installed without knowing the name of the package?
    For e.g. I want to know, if the MYSQL Server is already installed but I don't know the Package name.
    How can I find out the package name of needed software?

    Difficult.
    Assuming the string "MYSQL" appears somewhere in the package
    name or the package description, you can grep the output from
    "pkginfo". That is "pkginfo | grep -i sql" would list all installed
    packages that contain the substring "sql" with either upper- or
    lowercase letters.

  • General question about packages after the -Rs removal

    Hi !
    This is more of curiosity question . I was always wondering after i perform the command pacman -Rs package and then i try to install it again the downloaded size is 0 kb
    Meaning that the file is already stored on my hard drive . How can those packages be removed from my hard disk ?

    shak wrote:OK thanks for your help . The only relevant command i found is pacman with the  -n option , nosave. Is this the one ?
    No. the nosave option is for config files that would be saved as .pacnew if the option was not passed in.
    What you need is
    sudo pacman -Sc
    This will clean your cache and remove all the packages that are NOT installed on your system.
    If you want to remove every package from the cache then pass in an extra -c option
    sudo pacman -Scc

  • Question about packages

    Hello! I'm pretty new to java and had a quick question. Lets say I have a class called homework1 and another class called building. Each class is public but in separate packages. I want to create an object of
    building within the homework1 class (this class contains main). Normally you would simply type something along the lines of:
    Building house = new Building();however when I try this it doesn't work, says something along the lines of the type cannot be resolved. If I move homework1 into the same package as Building it works perfectly fine. What am I doing wrong? It's a requirement that the classes be in separate packages so I can't simply place them in one. Any help, tips or suggestions are greatly appreciated! Thanks.

    Classes from other packages have to be imported.

  • Question from package

    hello i m a beginner in java trying 4 a job. Kindly help me in solving these question.
    wat happens when you attempt to compile and run these  two files in the same  directory ?
    //File P1.java
    package MyPackage;
    class P1{
              void afancymethod(){
              System.out.println("What a  fancy  method");
    //File P2 .java
    public class P2 extends P1{
              public static  void main(string argv[]){
              P2 p2= new P2();
              p2.afancymethod();
    Options---
    1.Both compile and P2 outputs "What a fancy method" when run
    2.Neither will compile
    3.Both compile but P2 has an error at run time
    4.P1 compiles cleanly but P2 as error at compile time

    Hi Payal,
    Just check the file if it has closing braces. if the first file is
    package MyPackage;
    class P1{
      void afancymethod(){
       System.out.println("What a fancy method");
    <b>}</b>
    Then option 4 is correct ie. P1 compiles cleanly but P2 as error at compile time
    But if there is no closing braces for the class P1 then option 2 is correct ie neither will get complied.
    If you find my answers helpful, award points.
    Regards,
    Richa

  • Pacman question - list packages not in a group?

    More curiosity than anything else...
    I see that pacman -Qg will list groups and their packages.
    That seems like a nice way to upgrade a whole group at a time.
    Can pacman list just the packages outside of a group (which would imply they were manually installed by me)?
    thx

    Hello try this command:
    pacman -Qqe

  • Question about packaging material

    Hello all,
    i have encountered an interesting problem.
    I create an order with material r-1150 qty = 10.
    and in delivery i used 2 packaging material, each for 5 pc.
    1. PK-100
    2. PK-095,
    thus 2 HUs are created
    however only PK-095 can be displayed in delivery item list ( together with Material r-1150) .the PK-100 is missing.
    and in the following TO, by picking , i can also only confirm the material and PK-095. and the material qty = 10 .
    then I tried to package with only pk-100, and it is still missing from the delivery item list.
    one thing more weird is , if i change manually in Picking the pk-100 to pk-095, even Pk-095 wont be displayed. Only when I empty the box, and delete the HU and create a new HU with Pk-095, then it could be displayed.
    So do you know how to control this ? and where i can configure to hidden and display the packaging material ?
    thanks!
    regards
    Recke

    Hello, Sridhar,
    first, thanx for ur answer,
    but I think u misunderstood it.
    In the first 1. example
    In the delivery, I packed the qty 10 into 2 different packaging material
    1. PK-100 ---- 5 pc
    2. PK-095 ---- 5 pc.
    but in the item list of delivery, i can only see PK-095, and the following TO, I can pick the total 10 pc and PK-095
    but the PK-100 is missing ( despite that it contains 5 pcs)
    In the 2nd example.
    I only use PK-100 to pack in delivery, but still missing in the item list. That means only my 10 pc product is there.
    see attached file
    in my example 3
    I only use PK-095 as packaging material, it displays together product.with out any problem.
    so do u know what is the matter here ??

  • XFS woes, and question on packages

    Alright. I run all my systems on XFS. Just recently, I got hit by an an obscure bug, causing / to shut down, thereby making the system unusable without a reboot. This bug is fixed in xfsprogs 2.8.10... which would be great if one of the libs for xfs_repair wasn't in the unusable area of the filesystem. I would greatly appreciate it if someone could send me a statically linked copy of xfs_repair... which brings me to my second topic, which probably shouldn't go here, but I'm putting it here anyway:
    Why the bleep aren't fs repair programs - ext2fsck, , reiserfsck, xfs_repair, etc. - compiled statically to begin with? Just in *case* something like this happens? It would save quite a number of problems... hell, even just a -static package would be nice. Something to save these kinds of problems.
    ~celti

    Post a feature request, if you feel that strongly about it. Personally, I only ever do rescue/repair work from a Live CD, with my partitions unmounted - also the best way to fix your current problem, IMO.

  • Workspace Question on Packages

    I have crated a couple of classes and packaged them. However the
    workspace in JDeveloper doesn't separate them by packages. What
    should I do?
    Thanks.

    In JDeveloper 3.2.3, you can view the class hierarchy of a class
    by selecting the class with you mouse and right-clicking on it.
    You can then choose "Class heirarchy". You can see class and
    package information in the navigator and structure pane.
    In Oracle9i JDeveloper, you can view a project by package
    structure by setting some options in the ide. One way to do
    this is to click on the project. At the top of the System
    Navigator you can select a "Show Categories" button. At this
    point you will see a "source node". Click on the "source node",
    and again at the top right of the System navigator, select a
    button that will let you sort by "File List, Package Tree,
    Package List, or Directory Tree". The Package Tree or List will
    display your classes in the System navigator according to
    package structure.
    I have crated a couple of classes and packaged them. However the
    workspace in JDeveloper doesn't separate them by packages. What
    should I do?
    Thanks.

  • One question about package

    this why?
    E:\com\mysite\io>javac FileSize.java
    FileSize.java:1: ';' expected
    package com.mysite.io;
    source code as follows
    package com.mysite.io;
    import java.io.*;
    public class FileSize
    public static void main(String[] arg)
         System.out.println("java FileSize <Path>");
    }

    You need to compile classes that belong to packages from the package root directory.
    E:\>javac com/mysite/io/FileSize.java

  • Problems/questions with packages

    I am having problems with an exercise I am completing from my java tutorial concerning packages. I have created the folder "mypackage" on drive C, and added a classpath reference to this folder in autoexec.bat.
    My source file Item.java begins with the following line:
    package mypackage;
    The source compiles without error messages, but the item.class file it creates appears in the working directory not the "mypackage" directory. It is my understanding that the package name is analagous to the folder names on the machine. Shouldn't the class be under the appropriate folder named for the package? What am I missing here?
    Thanks,
    Mike

    Gaurav,
    I was able to create the packages as you suggested, but the program which uses those packages seems to be having problems I am using package j21work.mypackage
    for the item and storefront, but when I try to compile the giftshop program which accesses those two modules, I get all sorts of errors like the following:
    ^
    GiftShop.java:15: cannot resolve symbol
    symbol : method getName ()
    location: class Item
    "\nName: " + show.getName() +
    ^
    GiftShop.java:16: cannot resolve symbol
    symbol : method getRetail ()
    location: class Item
    "\nRetail Price: $" + show.getRetail() +
    ^
    GiftShop.java:17: cannot resolve symbol
    symbol : method getPrice ()
    location: class Item
    "\nPrice: $" + show.getPrice() +
    ^
    GiftShop.java:18: cannot resolve symbol
    symbol : method getQuantity ()
    location: class Item
    "\nQuantity: " + show.getQuantity());
    ^
    13 errors
    The programs are examples from the book Java 2 in 21 days. The only changes I have made are to point to different packages for the package and import statements. I have printed the code below. Can you please tell me where my problem is? I'm stumped.
    item.java
    package j21work.mypackage;
    import java.util.*;
    public class Item implements Comparable {
    private String id;
    private String name;
    private double retail;
    private int quantity;
    private double price;
    Item(String idIn, String nameIn, String retailIn, String quanIn) {
    id = idIn;
    name = nameIn;
    retail = Double.parseDouble(retailIn);
    quantity = Integer.parseInt(quanIn);
    if (quantity > 400)
    price = retail * .5D;
    else if (quantity > 200)
    price = retail * .6D;
    else
    price = retail * .7D;
    price = Math.floor( price * 100 + .5 ) / 100;
    public int compareTo(Object obj) {
    Item temp = (Item)obj;
    if (this.price < temp.price)
    return 1;
    else if (this.price > temp.price)
    return -1;
    return 0;
    public String getId() {
    return id;
    public String getName() {
    return name;
    public double getRetail() {
    return retail;
    public int getQuantity() {
    return quantity;
    public double getPrice() {
    return price;
    Storefront.java
    package j21work.mypackage;
    import java.util.*;
    public class Storefront {
    private LinkedList catalog = new LinkedList();
    public void addItem(String id, String name, String price,
    String quant) {
    Item it = new Item(id, name, price, quant);
    catalog.add(it);
    public Item getItem(int i) {
    return (Item)catalog.get(i);
    public int getSize() {
    return catalog.size();
    public void sort() {
    Collections.sort(catalog);
    giftshop.java
    import j21work.mypackage.*;
    public class GiftShop {
    public static void main(String[] arguments) {
    Storefront store = new Storefront();
    store.addItem("C01", "MUG", "9.99", "150");
    store.addItem("C02", "LG MUG", "12.99", "82");
    store.addItem("C03", "MOUSEPAD", "10.49", "800");
    store.addItem("D01", "T SHIRT", "16.99", "90");
    store.sort();
    for (int i = 0; i < store.getSize(); i++) {
    Item show = (Item)store.getItem(i);
    System.out.println("\nItem ID: " + show.getId() +
    "\nName: " + show.getName() +
    "\nRetail Price: $" + show.getRetail() +
    "\nPrice: $" + show.getPrice() +
    "\nQuantity: " + show.getQuantity());

  • [SOLVED] Question about package updates and ABS

    Hello,
    I have manually compile my kernel in order to apply a patch my laptop needs to suspend. So I use abs and customize the pkgbuild. A few days ago when the update for kernel26-2.6.33.3-2 came out, I thought I'd just refresh abs, rebuild, and then I'd be up to date. But instead now pacman -Syu tells me that there is still an update for the kernel.
    Does building from ABS not get you the latest package update?
    Also, what exactly is the package update compared to a software update? I'm guessing that it is an arch only update to the package but the software itself is the same version. Or am I totally off?
    Thanks for the help!
    Last edited by Fingel (2010-05-12 03:42:38)

    When building via ABS, the package installed gets its version from the PKGBUILD ($pkgver-$pkgrel).  Pacman just looks at available version vs installed version to tell if you should upgrade.
    Your abs tree was probably just not up to date; just because pacman -Syu says your mirror has a package, doesn't mean building via abs _at that moment_ will get that version.
    Be sure to run `abs` to update your tree, then when you're editing the PKGBUILD, check which version it's building.  In some cases, you can simply increment those numbers right in the PKGBUILD before building as source files are often fetched based on those variables, etc. -- but I don't know if I'd recommend that when building something like the kernel.
    Last edited by brisbin33 (2010-05-11 17:08:12)

  • A question about package,help.thank you

    i want to put HelloWorld.class input package myfile,but the subfolder myfile did not appear.
    i want to know why.
    thank you.
    i am a beginner.
    package myfile;
    public class HelloWorld
         public static void main(String[] args)
              System.out.println("hello,world");
    }

    folder will not appear. u have to create it and then put ur program inside it and run it from there.
    result will be on dos prompt or inside ur editor: "hello world" bye,
    Samir

Maybe you are looking for

  • Reader Extended PDF not working for some users

    I've created a document in Adobe X Pro and saved it as a Reader Extended PDF with Enabled Commenting & Markup. Most users are having no problem adding comments (by attaching a file) but I have a few users having issues (one with Adobe Reader 9 for Ma

  • SRM 7.0 Central Contract- Distribution to backend failure

    Hello experts, We are implementing SRM 7.0 Central contracts scenario with PI. The Contracts get created and Released but the problem is that the Distribution to backend fails. The Status in BBP_PD shows 'Distribution Incorrect' and the RZ20 gives an

  • Nokia lumia 625 - losees date & time settings when...

    Hi should my 625 lose the date & time settings when the battery goes flat -  mines done it twice now only had the phone since last wednesday

  • LDAP as a user source in UME

    Hi all, We have a concern regarding the user source to be selected at UME level. At CUP level you can also set the user source for user details. Our questions here: 1) Is there any relationship between such user source configuration? 2) Which is the

  • Credit Card Transaction details

    Hi, Can somebody tell me where can I can all the credit card transactions? through PRCC we will upload the transaction details. Where will those be saved? I want to fetch the transactions in a program. How can that be done? Thanks a lot!1