Help! Cant import my own classes?

Hi all, I really need some help.
I created a swing browser application in my working folder called Swiki.
Then I found a open source package that I want to use some of its classes.
I put that package into a subfolder (cos it has many subfolders itself).
I am having a problem importing that package into my own browser.java.
I tried:
import Kizna.*;
OR
import Kizna.src.com.kizna.*;
when I try to create an instance of one of the classes:
public HTMLParser myParser
The error says:
"HTMLParser.java": Error #: 901 : package com.kizna.html stated in source C:\Swiki\Kizna\src\com\kizna\html\HTMLParser.java does not match directory Kizna.src.com.kizna.html at line 1, column 19
can someone help?
thanks
TC

When the compiler and runtime are trying to find files, it converts the import statements to directories, so:import com.kizna.html.*;will look under a directory structure "com/kizna/html/". Then, it will look through your classpath and look to see if this directory structure exists in any of the directories specified in the classpath. That means, if your classpath is ".;C:\SomeDir;C:\AnotherDir", it will first look for class files in ".\com\kizna\html\". If it doesn't find the file it is looking for in there, it will look in "C:\SomeDir\com\kizna\html\". If it still doesn't find the file, it looks in "C:\AnotherDir\com\kizna\html\". If the file doesn't exist in any of these, you will get a compiler error.
Points to remember:
1)     Classes in a package, when compiled, must always be in a directory tree that matches the package structure. That is, if you have a class called MyClass in package mypackage.subpackage, then the "MyClass.class" file must be in a directory called "subpackage" which in turn is in a directory "mypackage".
2)     Your import statements must match the actual package name of the class. You must import "mypackage.subpackage.*" above; importing "subpackage.*" will not work.
3)     Your classpath must consist of all the base directories of your package directory tree. In the above example, your classpath must include the directory that contains the directory "mypackage".
Thus, the compiler will look through all combinations of <classpaths>/<import package tree>/MyClass.class to find the file for class MyClass. Here, <classpaths> are the paths given in your classpath and <import package tree> are thre directory structures for the packages you import. So, in your case, you want your classpath to include "C:\kizna\classes" and your import statement to be "import com.kizna.html.*". Note that including "C:\kizna\classes\com" in the classpath and importing "kizna.html.*" will not work (even though the combination gives the correct "location") because your import statement does not match the actual package name given to HTMLParser. While this may seem strange that this isn't allowed, it is done to ensure that classes are unique (classes may use the same name if they are in different packages).

Similar Messages

  • HELP: Import my own class in JSP ???

    Hi, all!
    I read many previous topics in this forum but no one works for me!
    Please someone help me!
    I'm using Tomcat 4.1.12 and my JSP scripts work just fine, but I need to import my own .class file. I just don't know where to put it so Tomcat can find it!?
    I have this environment variable:
    JAVA_HOME=.;c:\jdk1.3.1
    And in my code I'want to place something like this:
    <%@ page import="myClass" %>
    But I get a "can not resolve symbol" exception.
    Thanks for readind this, and please help if you can!
    Bye.
    adriano

    Within the Tomcat directory, under your application directory place the class file/s into the WEB-INF/classes directory. If your classes are part of a package place the entire directory structure of the package under the WEB-INF/classes directory.
    The import in the JSP is the same as for any Java class.
    Hope this solves your problem.

  • Importing my own classes

    I have 2 simple classes in the same directory and I'd like to test the use of import to import one class into the other. Upon compilation of the class thats doing the import, I get a compilation error. Herewith the details, where could I be getting it wrong.
    ****code for class to be imported****
    import java.util.Date;
    public class printer
    public void print()
    System.out.println(new Date());
    System.out.println("Hello World");
    --The above code compiles with no problems.
    ***Code for the main class that imports the above*****
    import printer;
    public class myapp
    public static void main(String[] args)
    (new printer()).print();
    -upon compiling the second class above, myapp.java, I get the following errors:
    C:\java\source>javac myapp.java
    myapp.java:1: '.' expected
    import printer;
    ^
    myapp.java:1: ';' expected
    import printer;
    ^
    2 errors

    Moreover, classes do not need to import any class which is in the same package as their own, and since your printer class is in the default package (if you call that a package) you shouldn't need to import it into myapp anyway

  • Problem to Import my own classes

    I try to import own classes to unother class
    I have all classes in the same map
    import StockTablePanel;
    when I tried to compile the code it says
    �.� expected
    StockTablePanel;
    What is wrong?

    I try to import own classes to unother class
    I have all classes in the same mapAlso if by the same map you mean the same folder then you don't even have to import the class.

  • NullPointerException - importing my own class to JSP

    Hi.
    I'm writing a JSP page. I also made a class in WEB-INF/classes/org/MyXml.class. When I try to run this class from console, there is no problems at all. But if i try to use function from that class in JSP, i get this (the same error i get whichever function i try to use (btw, all functions are static, as they should be, right?)):
    java.lang.NullPointerException
         org.MyXml.CountProducts(MyXml.java:46)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:75)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    I used this class like this:
    <%@ page import="org.MyXml" %>
    <%
    MyXml.CountProducts();
    %>
    I'm also a bit confused, it says that error is on line 46. Well, there's just a comment!
    Please help. Thanks.

    pqeuens,
    MyXml is his class. his methods are static, so, import="org.MyXml.*" won't work. It would either be import="org.*" or import="org.MyXml" (which he has)
    paull1911
    "What file are you looking at to find line 46? It is the java file (a servlet) corresponding to the jsp file."
    It should actually be in the org.MyXml.java file. The stack trace line is:
    java.lang.NullPointerException
    org.MyXml.CountProducts(MyXml.java:46)
    someone_
    You know from the above error line that the error is in MyXml.CountProducts method. After making sure you are working with the most up-to-date version of the class, (if that doesn't help you get a more accurate line number) walk through the CountProducts method and see where you might be trying to access an object that has not yet been instantiated (either using someObject.someMethodOrMember, or someArray[index])

  • Import my own class into servlet problem

    Hello, everyone.. I fail to import java classes that i create myself into the servlet. I wonder what is the problem. I would feel grateful if anyone can solve my problem. I noe that if it is in the package let say myclass , C:\jakarta-tomcat-4.1.29\webapps\lis\WEB-INF\classes\myclass. It will be
    package myclass;
    import myclass.*;
    But, I put all my class file into below directory not in a package.
    C:\jakarta-tomcat-4.1.29\webapps\lis\WEB-INF\classes
    and i wish to include let say DBManager.class file into Login.class file which in in the same directory as above. What is the correct code i should put? Thanks for anyone who willing to help me out ~

    You don't need to import classes from the same package. They are automatically available in the same namespace. Just use them.
    package myclasses;
    import myclasses.*;  // this line does nothing
    import myctherclasses.*;  // this line is necessary to use classes from another package.Having said that though, it is always preferable to put your classes in a package. Classes in the "unnamed" package are not guarunteed to be available anymore.
    Particularly servlet classes which are not in a package aren't found by Tomcat.
    In short: always put your classes into packages.
    Cheers,
    evnafets

  • How to import  my own class in jsp file

    I have a jsp file in jsp\ directory and a class in web-inf\classes\ directory. How do I import the class in jsp so i can use it in my jsp file. Thanks,

    This is your lucky day, wennie.
    The correct forum to post this is:
    [http://forums.sun.com/forum.jspa?forumID=45]

  • Import my own class

    I created two classes in the same package (myclass). one of them is using another class. what is the syntext of import another class: I tried import myclass.* also import myclass.class1. it didn't work. Thanks,
    j

    For class1.java in mypackage directory:
    package mypackage;
    public class class1 { }
    For class2.java in mypackage directory:
    package mypackage;
    public class class2 { }
    For a file myclass one level out of mypackage:
    import mypackage.*;
    public class myclass {
    public static void main(String[] args) {
    class1 c1 = new class1();
    Something like that should work.

  • Can't import own classes...

    I'm very new to java. I rented a book called Java 2 Grand Cru to learn it on my own. It is based on Java 1.3 but I have 1.4 installed. Now I wanted to write a simple program with a class in an other directory. I added that directory to CLASSPATH so my compiler could find it. These are the 2 programs
    import printer;
    public class test
         public static void main(String[] args)
              (new printer()).print();
    }and
    public class printer
         public void print()
              System.out.println("test");
    }So I want the first class to use the second to print "test"!
    Now I can compile public class printer without any problems but when I compile the first one, I get this:
    test.java:1: '.' expected
    import Printer;
                   ^
    1 error
    Process Exit Code: 1
    Time Taken: 00:00
    i don't get it. Is there anything changed with the import instruction in the new version of Java2?
    regards

    It is the error of my code but probably I did something bad with the copy paste thing :-)... The 'P' should be a 'p'
    Anyhow, I don't understand your first comment. 'printer.class' isn't a default package. I made it myself...
    regards

  • Cant import classes

    i cant compile a file because i keep getting the folowing errors
    I:\Huffman(7-11-2001)\unpack.java:18: Class Huffman not found in import.
    import Huffman;
    ^
    I:\Huffman(7-11-2001)\unpack.java:19: Class node not found in import.
    import node;
    ^
    both classes ARE in the same folder...
    does anyone know how to fix this?

    seems that u need to include working directory in classpath.
    set classpath=.;%classpath%

  • When my buddy list comes up, i try to double click my buddies name to start a chat and nothing happens. i could receive instant message but cant start my own or reply. someone please help!

    I have a macbook pro and on accident deleted ichat but reinstalled it using the cd, when my buddy list comes up, i try to double click my buddies name to start a chat and nothing happens. i could receive instant message but cant start my own or reply. someone please help!

    Hi,
    DId you download and Install the COMBO version of the last Update that you did ?
    iChat on the Install Disk is likely to be several versions behind where your OS has been Updated to.
    It needs to Match the OS level.
    iChat Updates come in the OS Updates.
    You need to run the Updater manually as Software Updates keeps records of what it has done and thinks iChat is up to date.
    If you are on Snow Leopard then the COMBO version of 10.6.7 is here
    If you are on Leopard then the COMBO for 10.5.8 is here
    Googling Mac OS X 10.x.x COMBO where x.x is the version you are up to will generally find the link to the right page if you are at a different OS version.
    <
    8:36 PM      Thursday; June 16, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
     Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Importing vs. extending classes

    ok, thanks for replying, ok then, what is the difference between importing a class and extending a class, i know that when you extend you add all the properties/methods of that class to your own class, but im still un sure of what this actually does for you and your program, im pretty confused on the topic and i couldnt find the difference between the two on the internet, also how do you know which one of the two you need to do? thanks, any help is appreciated

    This is what i understand so for (i got this from my book) :
    Inheritance is the is the system of extending a class to create a new class. All the classes so far have been created by extending the MovieClip class.
    When you see the keyword 'extends' in the class definition, you know that inheritance is at work:
    public class NewClass extends MovieClip
    This allows the new class to 'inherit' all the properties and methods of the class it extends. The new class can then use all those properties and methods in addition to any new properties and methods that the new class defines.
    ok, so i understand extending classes, but its still the importing part which still confuses me, i am a VERY beginner, so if you could explain it in very plain terms i'd really appreciate it, thanks!

  • Problem with creating my own class...

    Hi all,
    Purpose with this program:
    I want to create my own class StringThing which take a string parameter and transform the content toUpperCase().
    I have created a simple class StringThing which look like this:
    class StringThing {
    public String upperize (String u) {
    u.toUpperCase();
    return u;
    }And my class where I use the StringThing looks like this:
    import java.io.*;
    class UseStringThing{
    public static void main (String arg[]) throws Exception {
    BufferedReader keyboard = new BufferedReader(
    new InputStreamReader(System.in));
    String s,p;
    System.out.prinln("write a sentence!");
    s=keyboard.readLine();
    StringThing thing = new StringThing();
    p=thing.upperize(s);
    System.out.println(p);
    }Am I not supposed to transform my string parameter in my class by using for instance toUpperCase()? Or is there some fundamental rule or piece of code which I forgot?
    Thanks in advance,
    /Beginner-T-who-ripps-his-hear-over-this-small-problem

    Strings cannot be modified. What this line does:
    u.toUpperCase();
    is to create a new String object. toUpperCase() returns the newly created string and you are ignoring the returned value. What you want to do is:
    return u.toUpperCase();
    or
    u = u.toUpperCase();

  • Sony HDR-XR520, cant import into FCE 4.1 on my iMac

    Can anyone help? I have just bought this new AVCHD camera and when I open FCE log and transfer wont work. Doesnt recognise the camera at all. I have also copied over the folder of the camera but the files appear dimmed out and cant import that way either.

    Hi Tom, I am using the 1920x1080 (60i) codec setting. I have had a play around with the others but same result. Have tried the add folder, top level but wont import, it just keeps going through the levels and at the end they are dim.
    This model has not been out long and has built in GPS. I wonder if FCE is incompatible at this stage? Shouldn't be but have run out of ideas!

  • How to import user defined class in UIX page?

    Does anyone know how to import user defined class in UIX page so that the class can be called in the javascript in the UIX ?
    Thks & Rgds,
    Benny

    what you are referring to is not javascript.
    it is JSP scriptlets. These are very different.
    In order to keep a strict separation between View and Controller, it is not possible to run arbitrary java code from within your UIX code.
    However, you can run java code from within a UIX event handler; see:
    http://otn.oracle.com/jdeveloper/help/topic?inOHW=true&linkHelp=false&file=jar%3Afile%3A/u01/app/oracle/product/IAS904/j2ee/OC4J_ohw/applications/jdeveloper904/jdeveloper/helpsets/jdeveloper/uixhelp.jar!/uixdevguide/introducingbaja.html
    event handler code is run before the page is rendered.

Maybe you are looking for

  • WAD generic template

    IN BI 7 I transport a generic template in QUALIT,  in SPRO==> Settings for Reporting and Analysis==>BEx Web==> Set Standard Web Templates I setted the ad hoc analysis with =ZANALYSIS_PARTTERN_XXXX which I created in DEV and transported in QUALIT then

  • Cannot import dvd

    hello, i am trying to import files into imovie from a dvd already made (not by me) so i can save files as quicktime and use on a website. i am not very experienced in imovie, so please forgive my stupidity... the dvd has 2 folders, OpenDVD, and VIDEO

  • Manual tabular form and query based LOV

    Happy new year everyone! Okay so, I've run into an error when making one of the fields in a tabular form into a select list. report error: ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too

  • XI async Message are processing very slowly

    Hi All, We are processing 200000 IDOCS from ECC to External system webmethods using XI. The messages are taking too long to process in XI. XI is processing 1000 per hour on an average. Please let me know how to tune the system to process more quickly

  • LR Rankings not visible in Bridge

    I am using Bridge CS2, 1.0.4.6 And Lightroom 1.0. I have done rankings in Lightroom, and then I cannot see them in Bridge. I want to do my sorting in Bridge. What is particularly strange is that when I did Lightroom rankings once last week, the ranki