Problems compiling with packages

Hi,
I wonder if anyone could help me.
I have had problems compiling using a package. I have altered the classpath in autoexec.bat with:
SET CLASSPATH=%classpath%;C:\jdk1.3.1_02\classes;.
the package class files are stored in C:\jdk1.3.1_02\classes\helliker\id3
and I have imported the class with:
import helliker.id3.*;
I am getting the following error:
C:\My Documents\Uni work\mp3 project\test\Driver.java:1: package helliker.id3 does not exist
import helliker.id3.*;
^
Can anybody help?
Thanks,
Dave

Perhaps the version of Windows you are using does not use autoexec.bat. For example, in NT and XP, you set Classpath using ControlPanel/System/Advanced/Environment Variables.
Perhaps there is a typo in your Classpath, for example an extra space.
On a command line, try this:
javac -classpath C:\jdk1.3.1_02\classes C:\My Documents\Uni work\mp3 project\test\Driver.java
If that works, then definitely Classpath is not set as you think it is.

Similar Messages

  • Compilation with packages is different in J2SE 1.4.1 ?

    Hi there !
    I've just installed J2SE 1.4.1_01 in my Win NT 4.0 computer.
    Some of the files that belong to packages compiled just fine with JDK 1.2.2 but don't compile with J2SE 1.4.1_01.
    The same is true when I try to compile Java2D in the demo\jfc directory.
    In project NumberFormatTest I have the following classes:
    =====================================================================
    d:\MyPrograms\Java\NumberFormatTest\NumberFormatTestFrame.java
    package NumberFormatTest;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    import tools.*;
    public class NumberFormatTestFrame extends Frame
    implements ActionListener, KeyListener, WindowListener
    =====================================================================
    d:\MyPrograms\Java\Tools\JCTextField.java
    package tools;
    import java.awt.*;
    public class JCTextField extends TextField
    =====================================================================
    d:\MyPrograms\Java\Tools\JCDecimalTextField.java
    package tools;
    import java.text.*;
    import java.util.*;
    public class JCDecimalTextField extends JCTextField
    d:\MyPrograms\Java>javac Tools\JCTextField.java
    compiles OK
    d:\MyPrograms\Java>javac Tools\JCDecimalTextField.java
    does not compile successfully with the error,
    Tools\JCDecimalTextField.java:67: cannot resolve symbol
    symbol : class JCTextField
    location: class tools.JCDecimalTextField
    public class JCDecimalTextField extends JCTextField
    pointing to the J in JCTextField
    d:\MyPrograms\Java>javac NumberFormatTest\NumberFormatTestFrame.java
    also doesn't compile with with "cannot resolve symbol" errors, when it tries to use JCDecimalTextField.
    It seems to me that classes defined by me to extend another class defined by me (JCDecimalTextField) and inside a package (tools) aren't being found by javac.
    However JCTextField is defined by me, extends TextField (from java.awt.*), is inside package tools and compiles OK.
    This stuff didn't happen in JDK 1.2.2.
    What the hell has changed with J2SE 1.4.1 ???
    My PATH has C:\Program Files\jdk\bin (among other directories)
    My CLASSPATH is
    D:\MyPrograms\Java;C:\Program Files\jdk\lib\tools.jar;C:\Program Files\Java\j2re1.4.1_01\lib\rt.jar;.;
    I strongly suspect that something has changed after JDK 1.2.2 in the way packages are handled by javac. I've tried searching in forums and other sun java documentation but couldn't find an answer to my problem.
    Can anyone please help me ?
    Any hint, suggestion or Internet site with appropriate documentation, would be highly appreciated as a means to end this 2 day nightmare.
    Thanks in advance,
    MGoncalv

    This issue has already been solved.
    J2SE 1.4.1 is case sensitive with regard to package directories.
    My tools package files must in subdirectory tools (but not Tools).
    This problem didn't happened with JDK 1.2.2
    For more details please take a look at
    Cannot resolve symbol
    from Feb 10, 2003 11:46
    by MGoncalv

  • Problems compiling Zaptel package [SOLVED-ISH]

    Hey guys, I'm on an Arch64 system and I'm having problems compiling Zaptel (a dependancy for Asterisk).
    Here's the pastebin of the errors I get from the Zaptel makefile: http://pastebin.com/776475
    Here's my analysis so far:
    There's a line in the Makefile for the zaptel driver that goes like this:
    make -C /lib/modules/2.6.17-ARCH/build/ SUBDIRS=/home/woogie/zaptel/src/zaptel-1.2.8 modules
    This line activates the kernel's makefile in order to build modules, but specifies that the source directory for zaptel should be included in the make process.
    Then things go down the proverbial drain - linux/err_kernel_only.h gets included in the build process, which is designed to do one thing only - stop the build process. So I'm not entirely too sure what's going on here. Is there something misconfigured on my system, or is the Zaptel build system flawed somehow, such that I need to compensate for it?

    Further information:
    I've manually run the problematic make command from /lib/modules/2.6.17-ARCH/build on my own. After reading the kernel makefile documentation, I've learned of the V=1 flag to show me exactly what's going on. The failing command is this one:
    gcc -Wp,-MD,/home/cestus/zaptel/src/zaptel-1.2.8/.zaptel.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-unknown-linux-gnu/4.1.1/include -D__
    KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O2
    -fomit-frame-pointer -m64 -mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks -Wno-sign-compare -fno-asynchronous-unwind-tables -fun
    it-at-a-time -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wdeclaration-after-statement -Wno-pointer-sign -I. -Iinclude -O4 -g -Wall -DBUILDING_T
    ONEZONE -m64 -DSTANDALONE_ZAPATA -DZAPTEL_CONFIG="/etc/zaptel.conf" -DHOTPLUG_FIRMWARE -I/home/cestus/zaptel/src/zaptel-1.2.8//include
    -I/home/cestus/zaptel/src/zaptel-1.2.8//include/oct6100api -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(zaptel)" -D"KBUIL
    D_MODNAME=KBUILD_STR(zaptel)" -c -o /home/cestus/zaptel/src/zaptel-1.2.8/zaptel.o /home/cestus/zaptel/src/zaptel-1.2.8/zaptel.c
    I've figured out that the bit which causes the failure is "-include include/linux/autoconf.h", because autoconf.h just includes the "err_kernel_only" header automatically, which then slays the build process. And I've also discovered that the Zaptel devs are uber-leet. They've found the magical -O4 level in gcc. You know, the one above 3, where the supported optimization levels in gcc are -O, -Os, -O2 and -O3 

  • 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());

  • How to compile with packages created by me

    I have created two packages:
    one is called agui and one is called agui.event.
    agui is located at c:\agui\src\a\agui and
    agui.event is located at c:\agui\src\a\agui\event.
    My class file is called HelloWorld and it is located at
    c:\agui\example.
    What should be the command line to compile my class file?
    is it
    c:\agui\example>javac -classpath c:\agui\src\a\agui *.java?
    I tried it, but it doesn't work!
    Thanks.

    Hi,
    When you are compiling a java file with a package you must use the -d option.
    Just for simplicity, if you change directory to the source file e.g. c:\test and the files have package name pack1 and filename File1.java -
    If you run javac File1.java it will compile fine but leave the class file in the default directory i.e. c:\test
    If you run javac -d File1.java the package name will be noted and new sub-directory for pack1 will be created with the new File1.class in it.
    Check it out using the -d option and not using to see the difference.
    bet kev

  • Problem compiling with IVParameterSpec

    I'm trying to build a password file that will be created by one program and read by a different one using CipherInput/OutputStreams. I believe that I need a repeatable key so that as I write the file, I can also read it.
    I'm trying to use cipher.init (Cipher.ENCRYPT_MODE, key, ivSpec) with ivSpec set to the same array of bytes in both my read and write routines. When I try to compile the write class, I get an error at my import statement for the IVParameterSpec.
    Line 78:   import javax.crypto.spec.IVParameterSpec;Error:
    [javac] C:\rat\jtim\src\com\baesystems\jtim\RemotePassword.java:78: cannot resolve symbol
    [javac] symbol : class IVParameterSpec
    [javac] location: package spec
    [javac] import javax.crypto.spec.IVParameterSpec;
    Do I need to load something else into the JDK to get IVParameterSpec? What could I be doing wrong?

    just a spelling mistake.
    javax.crypto.spec.IvParameterSpecThe "v" in Iv is the small V, not the capital V.
    Thanks. You'd think after 15 years of Unix, I'd be able to catch a case error.

  • Problem compiling with Swing

    I am new to java.
    I have recently installed jdk-1.3.1_01 and am able to compile and run basic java programs. However, when trying to compile HelloWorldSwing.java, I get the following error:
    HelloWorldSwing.java:6: error:Cannot find class "JFrame" [JLS 8]
    Is this a classpath problem? Please help!

    yes, I'm sure the code is right. What is strange is that when I first installed jdk, I was able to compile and run the swing program. Once I closed the terminal, though, and opened a new one, I was unable to compile. I'm using Linux Mandrake 8.1. Any ideas?

  • Problem compiling with a  final static statement

    I'm trying to compile a code that i obtained from jad. The error is:
    MethodInvoke.java:269: illegal start of type
    ^
    At the final of the code i got:
    static final
    {                //here appear the problem
    try
    pool = new ObjectPool(com.test.wsp.main.MethodInvoke.class);
    catch(Exception exception)
    throw new ExceptionInInitializerError("could not initialize the worker pool, exception=" + com.tess.hometop.gateways
    .utils.Utils.parse(exception));
    Could anyone explain me which is the problem?
    Thanks

    I'm trying to compile a code that i obtained from jad. The error is:
    MethodInvoke.java:269: illegal start of type
    ^
    At the final of the code i got:
    static final
    {                //here appear the problem
    try
    pool = new ObjectPool(com.test.wsp.main.MethodInvoke.class);
    catch(Exception exception)
    throw new ExceptionInInitializerError("could not initialize the worker pool, exception=" + com.tess.hometop.gateways
    .utils.Utils.parse(exception));
    Could anyone explain me which is the problem?
    Thanks

  • SUNWspro iostream error while compiling with SunStudio 10

    We are getting the following error when we try to compile the C++ code using SunStudio 10 on Sun Solaris Sparc server.
    We made couple of changes in the source code 1) whereever we have stream.h we replaced it with iostream.h and 2) include fstream.h whereever required.
    Can anyone tell us where did it go wrong.
    + /opt/SUNWspro/bin/CC -g -O -DHAWK -mt -lclntsh -lsocket -lnsl -I/export/home/StandardComponents/SC/include -I../../mylib -I../../include -I/opt/SUNWspro/prod/include/CC/Cstd -I. -I- -D_TRACE_ -c collectDborMtoInfo.c
    "/opt/SUNWspro/prod/include/CC/Cstd/iostream.h", line 20: Error: Use ";" to terminate declarations.
    "/opt/SUNWspro/prod/include/CC/Cstd/iostream.h", line 20: Error: A declaration was expected instead of "'\n'".
    "/opt/SUNWspro/prod/include/CC/Cstd/iostream.h", line 20: Error: Use ";" to terminate declarations.
    "/opt/SUNWspro/prod/include/CC/Cstd/iostream.h", line 20: Error: A declaration was expected instead of "'\n'".
    4 Error(s) detected.

    Remove the -I directive that points into the compiler installation. You should not have have -I or -L options that point into the compiler installation area, into /usr/include, or into /usr/lib. The CC compiler driver knows where to find system headers and libraries, and in what order to search the directories. If you force a different search order, you can break something.
    If removing -I/opt/SUNWspro/prod/include/CC/Cstd does not fix the problem, compiling with -P or -E will show you the preprocessor output, and looking at the lines with the errors will usually show the source of the problem quickly.
    BTW, you should be aware that the ".h" form of the C++ headers, like <iostream.h> and <fstream.h>, is not standard. Using them is not portable, because not all C++ implementations provide them, and those that do often have different content.

  • Problem compiling source file in package

    Hi, I have 5 source files which I have just packaged together and put in the same sub-directory, the problem is that when I try to compile the file with the main method I get the error message:"cannot read" then the name of the source file. I am compiling from the command line and setting the classpath as I compile with the statement:
    c:\j2sdk1.4.1\bin>javac -classpath c:\directory\package directory source file.java
    I'm not sure what I am doing wrong and the source files all compiled fine before I added the package statement to the files. Please any help would really be appreciated.

    It sounds like the java file your are trying to compile is not in the directory you are compiling from.
    Is this basically what you are doing?:
    Say the package name is mypackage.
    Assume we are O.K. with keeping source and class files together.
    Create a directory named 'mypackage' somewhere...C:\mypackage\.
    Put all the .java files in it (these .java files indicate that they are a member of the 'mypackage' package).
    At a command prompt, cd to the directory containing the 'mypackage' directory...'cd C:\'
    Compile the source files: C:\j2sdk1.4.1\bin\javac mypackage\*.java
    run the main class: C:\j2sdk1.4.1\bin\java mypackage.TheMainClass
    Basically, this says keep the files where you want them and point to javac, instead of moving everything under java/bin. btw it will save a lot of typing if you add java/bin to your PATH.
    Hope this helps.

  • Problem with "Package Spec" please help.

    Hello once again.
    I'm developing a master-detail form, so I'm using a "Package Spec" variable to hold the primary key value from the master form. The primary key value for the master is generated by a sequence.
    Here's the package spec:
    PACKAGE primary_keygen IS
    pkey varchar2(15); 
    END;Now the master table has the following "Before Insert" Trigger .
    CREATE OR REPLACE TRIGGER MASTER_NUM_GEN
    BEFORE INSERT
    ON MASTER
    FOR EACH ROW
    DECLARE
    primary_key_value varchar2(15);
    BEGIN
    select lpad(to_char(ref_gen.nextval), 4,'0')
    into primary_key_value from dual;
    primary_keygen.pkey:='ABC/'||primary_key_value;
    :new.Ref_Number:=primary_keygen.pkey;
    END;For the detail block. I have the following "Before Insert Trigger" to generate the primary key values.
    CREATE OR REPLACE TRIGGER DET1_NUM_GEN
    BEFORE INSERT
    ON DETAIL1
    FOR EACH ROW
    BEGIN
    if :new.M_ref_number is NULL THEN
    :new.M_ref_number:=primary_keygen.pkey;
    ENd if;
    END;Works quite fine if I have only one detail block. But if I have multiple detail blocks. Depending on the user's selection. i.e. After entering data into the master block, the user selects a detail block ('Letter type'- using stacked canvases for this purpose and radio buttons for selecting the view) and then Inserts data into it. here's what I do in the Detail block2.
    CREATE OR REPLACE TRIGGER OREF_NUM_GEN
    BEFORE INSERT
    ON DETAIL2
    FOR EACH ROW
    BEGIN
    if :new.O_ref_number is NULL THEN
    :new.O_ref_number:=pkey_gen.master_key;
    ENd if;
    END;Now the problem is that When I enter one record into detail1, works fine, but for the second time, when I try to insert another record. the master table gets a new reference number (primary key value) while the detail block gets the previous value that was used in the first record!, so that means 'pkey_gen.master_key' is holding the old value, while in my opinion it should hold the new value, I dont know whats wrong here. If I try to insert two consecutive records into the same detail table, I get an error saying "Unique Constraint voilated", becuase the variable is holding the old values.
    And lastly after it inserts the record into the database, I get a dialog box saying, "successfuly inserted 2 records into the database" and when I click ok, the Form closes by itself, any ideas on how to stop this?
    I'm really stuck here. Please help me out on this.
    Thanks.
    Note: I'm using Form6i with Database 10g.
    Message was edited by:
    fahimkhan82

    Hi,
    Maybe the best way to start is to try building a new form from scratch. For simplicity I will assume that you have one master and one detail table. Master table has a primary key and the detail table has a foreign key to the master. Based on this, with the forms you can create a database block based on your master table. Use the wizard. Again using the wizard, create a second block based on the detail table. You'll see a screen to prompt to create a relationship. Create one by selecting the master table and the right foreign key relation. Now take a close look to all triggers automatically created by the form. Also check the "Relations" object found in you master block object tree. Note that the foreight key column in the detail table has the "Copy Value From Item" property set to monitor the master block's primary key.
    This is the basic. You don't need the database triggers, except (in case you want to insert through, say, SLQPlus) the one for the master table, which will look like this:
    CREATE OR REPLACE TRIGGER MASTER_NUM_GEN
    BEFORE INSERT
    ON MASTER
    FOR EACH ROW
    BEGIN
    IF :new.ref_number IS NULL THEN
    select 'ABC/'||pad(to_char(ref_gen.nextval), 4,'0')
    into :new.ref_number
    from dual;
    END IF;
    END;
    Now you have to take care about the inserts in your form. Create PRE-INSERT trigger on the master block.
    IF :master.ref_number IS NULL THEN
    SELECT 'ABC/'||pad(to_char(ref_gen.NEXTVAL), 4,'0')
    INTO :master.ref_number
    FROM dual;
    END IF;
    Run the form and explore different situations to see how the form is keeping the data integrity.
    Compile with Shift+K (incremental). Sometimes forms blow just because not all of the trigers were compiled properly.
    Hope this helps...

  • Having problems compiling *.java with import javax.servlet.jsp......

    I've been trying to do the tutorials in a book titled Apache Jakarta-Tomcat as part of my introduction to JSP. I'm new to Java but do know the basics. I have on my machine Java 1.3, Java 1.4, Java FrameWorks 2.1 and Jython 2.1 on Win2000 Pro. So enough about my configuration. I have never worked with packages also.
    I downloaded the files from the books site due to the fact I make a lot of typos when hand coding Java (I've become a pretty good debugger of my own code). But everytime I go to compile the *.java I get error messages. So below you will find HelloTag.java and beneath that the error messages that are thrown when I try and compile it. I tested other bits of *.java and have had no problem compiling them. Is there a JSP module I'm missing?
    Am I doing something wrong or am I missing something from my configuration.
    Marijan Madunic
    package chapter2;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspTagException;
    import javax.servlet.jsp.tagext.TagSupport;
    public class HelloTag extends TagSupport
    public void HelloTag() {
    // Method called when the closing hello tag is encountered
    public int doEndTag() throws JspException {
    try {
    // We use the pageContext to get a Writer
    // We then print the text string Hello
    pageContext.getOut().print("Hello");
    catch (Exception e) {
    throw new JspTagException(e.getMessage());
    // We want to return SKIP_BODY because this Tag does not support
    // a Tag Body
    return SKIP_BODY;
    public void release() {
    // Call the parent's release to release any resources
    // used by the parent tag.
    // This is just good practice for when you start creating
    // hierarchies of tags.
    super.release();
    D:\Java\JDK 1.3\bin>javac HelloTag.java
    HelloTag.java:3: cannot resolve symbol
    symbol : class JspException
    location: package jsp
    import javax.servlet.jsp.JspException;
    ^
    HelloTag.java:4: cannot resolve symbol
    symbol : class JspTagException
    location: package jsp
    import javax.servlet.jsp.JspTagException;
    ^
    HelloTag.java:5: cannot resolve symbol
    symbol : class TagSupport
    location: package tagext
    import javax.servlet.jsp.tagext.TagSupport;
    ^
    HelloTag.java:7: cannot resolve symbol
    symbol : class TagSupport
    location: class chapter2.HelloTag
    public class HelloTag extends TagSupport
    ^
    HelloTag.java:14: cannot resolve symbol
    symbol : class JspException
    location: class chapter2.HelloTag
    public int doEndTag() throws JspException {
    ^
    HelloTag.java:20: cannot resolve symbol
    symbol : variable pageContext
    location: class chapter2.HelloTag
    pageContext.getOut().print("Hello");
    ^
    HelloTag.java:24: cannot resolve symbol
    symbol : class JspTagException
    location: class chapter2.HelloTag
    throw new JspTagException(e.getMessage());
    ^
    HelloTag.java:28: cannot resolve symbol
    symbol : variable SKIP_BODY
    location: class chapter2.HelloTag
    return SKIP_BODY;
    ^
    HelloTag.java:37: cannot resolve symbol
    symbol : variable super
    location: class chapter2.HelloTag
    super.release();
    ^
    9 errors

    Well, it looks like you've not got the servlet development kit JAR on your classpath. I think it'll probably be called servlet.jar on your system. Add that to the classpath if it's not already there.
    Incidentally, you've bumped into one of the areas Java's slightly lenient - declaring a method that looks like a constructor:
    public HelloTag() { }
    public void HelloTag() { }The first is a constructor, the second is a normal method. I'm assuming you intended to have the former instead of the latter.
    Anyway, hope this helps.

  • Hai ,problem with packages

    Hai all,
    i got a problem with user defined packages .i have one class under one package "sg.km" n the class name is kmc.class n i want to use that sg.km.kmc in some another class that is also a part of sg.km package .i hope i'll get reponses to my prob asap.
    thanks in advance
    yours
    srinu kumar reddy

    You should not need to import a class that is in the same package.
    You did not post enough information for me to give you a good answer. You should always post an error message along with any command you entered. All you said was, "i got a problem." We don't know if your problem is with compiling, running, jar file, applet, etc.
    You need to have a directory structure that matches your package. The kmc.class file a sg\km directory path. For example, c:\myjava\classes\sg\km\kmc.class. Then you need c:\myjava\classes directory in your Classpath both for compiling and running.

  • Problem when working with package???Please, help me!!!

    I got 3 .java files from one Java tutorial as follow:
    Server.java (in package mygame.server)
    Utilities.java (in package mygame.shared)
    Client.java (in package mygame.client)
    All the above files are placed in "E:\Java Programmes\source"
    After compiling, i got correspponding .class files:
    Server.class (placed in "E:\Java Programmes\class\mygame\server")
    Utilities.class (placed in "E:\Java Programmes\class\mygam\shared")
    Clients.class (placed in "E:\Java Programmes\class\mygame\client")
    But when i run Server.class which contains main method, i got error as follow:
    E:\Java Programmes>java class\mygame\server\Server
    Exception in thread "main" java.lang.NoClassDefFoundError: class\mygame\server\S
    erver (wrong name: mygame/server/Server)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    That was very puzzled for me. I cannot find out what wrong with my files. Please., any boby, help me!!! I always got this problem when working with package and managing files. Thanls a lot.

    java -cp "E:\Java Programmes\class" mygame.server.Server

  • NetBeans Problem with package, pls help.....

    Hi all, I have a package problem. With the following 2 classes, I can compile fine in dos with
    c:\java> javac WapDev3\*.java
    but wont compile in Netbeans 3.4 Pls help.
    The classes are
    -------------------class sample1 at c:\java\WapDev3------------------
    package WapDev3;
    class sample1 {
    public sample1() {
    System.out.println("hi");
    --------------------class sample2 at c:\WapDev3------------------
    package WapDev3;
    class sample2 {
    public sample2() {
    public static void main(String[] args) {
    sample1 osample1 = new sample1();

    I don't know for certain whether this is causing your problem, but in Netbeans, the package structure is considered to be identical to the directory structure, relative to the mountingpoint, so if your files are in java/wapdev, Netbeans wants you to make the package java/wapdev.
    This can be cured by mounting a subdirectory, using a relative mounting point.
    In your case, you should mount C:\java (I assume you've mounted C:\).
    Good luck.

Maybe you are looking for