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.

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

  • Problem in importing two different classes with same name...

    I have to import two different classes in my program with the same name....
    import org.apache.lucene.document.Document;
    import org.w3c.dom.Document;
    //    I AM USING THE DOCUMENT FROM W3C PACKAGE HERE....
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                     DocumentBuilder builder = factory.newDocumentBuilder();
                     InputSource is = new InputSource( new StringReader( tempString ) );
                     d = builder.parse( is );
                     NodeList images = d.getElementsByTagName("img");
                     int length = images.getLength();
                     for(int i = 0;i<length;i++)
                         Node image = images.item(i);
                         String tempAltText = image.getAttributes().getNamedItem("alt").getNodeValue();
                         altText = altText.concat(" ").concat(tempAltText);
                     }and the error i am getting is
    [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:20: org.apache.lucene.document.Document is already defined in a single-type import
        [javac] import org.w3c.dom.Document;
        [javac] ^
        [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:132: incompatible types
        [javac] found   : org.w3c.dom.Document
        [javac] required: org.apache.lucene.document.Document
        [javac] d = builder.parse( is );
        [javac] ^
        [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:133: cannot find symbol
        [javac] symbol  : method getElementsByTagName(java.lang.String)
        [javac] location: class org.apache.lucene.document.Document
        [javac] NodeList images = d.getElementsByTagName("img");
        [javac] ^
        [javac] Note: Some input files use unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] 3 errorsany idea ..how to resolve it
    Edited by: ping.sumit on Jul 16, 2008 3:39 PM
    Edited by: ping.sumit on Jul 16, 2008 3:40 PM

    now i changed the code to
    import org.apache.lucene.document.Document;
    import org.w3c.dom.Document;
    org.w3c.dom.Document d = null;
    try{
         System.out.println("in author");
                   URL url = new java.net.URL(urlString);
                   java.net.URLConnection conn = url.openConnection();
                   BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   while ((in.readLine()) != null)
                        //tempString = tempString.concat(in.readLine());
                        String temp = in.readLine();
                        tempString = tempString + " " + temp;
                   System.out.println("the string in author" + tempString);
                    in.close();
                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                     DocumentBuilder builder = factory.newDocumentBuilder();
                     InputSource is = new InputSource( new StringReader( tempString ) );
                     d = builder.parse( is );
                     NodeList images = d.getElementsByTagName("img");and their is only one error i am getting ...and that is
    [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:20: org.apache.lucene.document.Document is already defined in a single-type import
        [javac] import org.w3c.dom.Document;
        [javac] ^
        [javac] Note: Some input files use unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] 1 error

  • 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

  • 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).

  • 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])

  • 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]

  • Problem in importing an own image

    I am new to Mapbuilder. I need to use my own images as themes in my project. when I try to import a bmp or "gif" file by choosing Tools--> Import Image Option using MapBuilder, i am getting the error message "GeoRaster spatial extent update was not successful" in Dialogbox. In the Console the following
    error message is getting displayed.
    Wizard Selection Change - Page:1
    You chose to open this file: D:\12.bmp
    Wizard Selection Change - Page:2
    Wizard Selection Change - Page:3
    Wizard Finish called
    ImportImageThread running thread: Thread-6
    Importing File...
    Georeferencing...
    Updating Spatial Extent...
    Exception: ORA-13430: There is the attribute of NULL in GeoRaster object
    ORA-06512: "MDSYS.MD" and line 1723
    ORA-06512: "MDSYS.MDERR" and line 8
    ORA-06512: "MDSYS.SDO_GEOR" and line 893
    ORA-06512: Line 4
    It is very urgent. Please help me....
    - prabhakaran

    Thanks for the reply. The parameters of the bmp file are
    407 wide * 411 high
    Size: 491 KB
    Top Left Coordinate
    X: -180.0
    y: 90.0
    Resolution
    X: 0.033
    Y: 0.033
    I have also tried to import .tif image. For that i have got the error "Import of File was not successful"
    The parameters used for the .tif image are
    10800*5400
    166 MB
    Top Left Coordinate
    X: -180.0
    y: 90.0
    Resolution
    X: 0.03333333333333
    Y: 0.03333333333333
    In what basis resolution should be mentioned? how to calculate it?
    For "Import of File was not successful" Error, We have followed the Information given in the following URL.
    Import image in Map Builder
    But the same error is coming, while importing the .tif image. Please help me....

  • 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.

  • How to import GreenSock external classes?

    Hi, I'm having some problems in importing GreenSock external classes into my flash project.
    Line 27: import gs.*;
    Desktop\myFlashAPPS\twitter\src\zainu\twitter\MainClass.as, Line 27
    1172: Definition gs could not be found.
    Here is the directory tree:
    myFlashApp (contains myproject.fla)
         src
              zainu
                   twitter (contains MainClass.as and gs folder)
    MainClass.as:
    package zainu.twitter{

    You could try specifying the path to the gs folder as if you were importing it directly from the myproject.fla file.
    You should set up a classpath for external classes for your system so that Flash has a ready reference for finding them.  YOu can set this up via using Edit -> Preferences... -> Actionscript -> Actionscript 3.0 Settings... -> specify a source path.  Normally what people do is create a folder in a relatively general location and use that as their source path.   Within that they place a "com" folder, and within that com folder they place their subfolders for different classes they acquire from outside sources, such as your gs folder.  So when you want to import the gs classes you can use... import com.gs.*;
    There is a tutorial at gotoandlearn that explains this...   http://www.gotoandlearn.com/play.php?id=30

  • 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

  • Problem with import statement for user created classe

    I recently downloaded J2sdk1.4.0_03 before that I had jdk1.3 and never had this problem.All the files other than named package I import for my
    application does not compile.But when I commented that out it work just fine.
    any help is appreciated

    thanks
    It makes sense not to import non-packaged class.
    My other problem is with JDBC ODBC.I have a Dell system with Windows XP.
    I registered my User Data Source to ODBC with MS Text driver(.txt , csv).When the code reaches at the .executeUpdate(CREAT TABLE CUSTOMERS)
    it throws an exception
    sQLException 3:java.sql.SQLException: [Microsoft][ODBC Text Driver] Cannot modify the design of table 'CUSTOMERS'. It is in a read-only database.
    Do I really need to change the attribues or some thing else.
    How can I chane the attributes of the database.Never had problem with windows 98.

  • Problem in importing a class

    hi,
    C:\sample:
    My.java (this file is not a package and is directly inside the classpath)
    c:\sample\mypackage:( the package is mypackage)
    test.java extends My
    Is it possible for a class in a package to extends from a class in the Classpath here in this case it is (C:\sample )
    is it possible to give like this in the test.java
    package mypackage
    import My;
    public class test extends My {
    It is giving error :
    . expected in import:
    and without import it gives as Class not found error.
    Is there any way to resolve this, ie referring a class outside the package
    regards,
    Deepa

    well... that's not quite true... i did try out the
    example with one class in no package, and a class ina
    package that imports the first... and it works for
    me... jdk1.4 too... the only problem is, i had toset
    the path to the parent of the directory containingthe
    first (no package) class...If I understand correctly, then this is news to Sun.
    See item #8, second bullet.
    http://java.sun.com/j2se/1.4/compatibility.html
    ummm... sorry if i'm more 'Duh...' than usual (this is more than hangover!!!).... but the bulletted item refers to serializable classes... thatzz not what she's talking about... or is she..!??!
    if i have a clas NoPackage.java in c:\dir1\dir2\NoPackage.java
    and class HavePackage.java in c:\dir1\dir2\dir3\HavePackage.java, (with package named dir2.dir3)
    i have my classpath set to c:\dir1.... and it works fine too.. sooooooo... what am i missing here.???

Maybe you are looking for

  • ERROR IN SAVING MARKETING PLAN

    HI forum when i saving the marketing plan in 5.0 getting the error like can't get RFC for SEM. anybody suggest how to solve this.

  • Logic Pro 9 won't save, hangs and quits??

    I have just installed the latest software Logic Pro 9 with the latest update. It won't save it hangs and quits?? Dean

  • Apple DRM video error iOS 8

    I upgraded my iPad to iOS 8.01. I am no longer able to view apple store purchased video via the Seagate Media application. https://itunes.apple.com/au/app/seagate-media/id431912202?mt=8 Previously when I tapped on a store bought video it would switch

  • Parse the URL components !

    hi all ! Is there any function module which can parse the survey URL components so that i can use it in PBO for some functionalities. regards sachin

  • RemoteApp rdp file connection restriction

    Hi all, So I have a RemoteApp deployment that gives users certain applications from the RDWeb site based on security groups. I've connected a few people using the RemoteApp and Desktop Connections in Control Panel on their Win7 workstations. I've not