Java package

Hi I'm facing some problem with package. Currently my project import some classes from the file abc.jar. Before including the package keyword for my new class, everything compiles.
However after I tried adding for example package testing; at the top of the .java files. I begin to get error like:
cannot resolve symbol class xxx -> which is suppose to retrieve from abc.jar. The first thing that came into my mind is the classpath, have double confirm on the classpath for the .jar files and its already specified in the classpath. The thing that puzzle me is why adding my new class to a package will have compilation error like the above.
Anybody faced this problem before or have little hint on how to solve it? Kindly post your advice. Thanks! cheers

xpy wrote:
Hi, its that statement.... Cause I tried compiling with and without the package keyword and the result is fail and success respectively.This tells us very little other than that you're probably making a mistake. Most Java code is in packages; this works for most people.
Its really puzzled me. Btw the way the .jar file which I set in my classpath have no directory. Wait. Do you mean to say that the classes in the jar file are all in the default package?
Who created this crazy jar file?
When code is in a package, it cannot access classes in the default package. This is why it's generally bad to put classes in the default package if they're non-trival. You certainly shouldn't any class that you expect to be reused and thus might put it in a jar file, in the default package.
Therefore after setting the classpath to point to the .jar file, therefore I use it directly in my new class without importing. Do you think this is the reason that caused the problem?Yeah.
Stop using that jar file, because the person who created it doesn't know what he's doing.

Similar Messages

  • Import Java package in JSP

    I hope this is an appropriate forum for this query.
    I want to be able to access a user-created Java package in JSP.
    I have this code:
    <%@page import="TPClass.*" %>
    <%
    xxx = TPClass
    session.setAttribute("response",xxx.GetTPResponse());
    %>
    The error display points to TPClass in the import statement with the message "TPClass not found".
    TPClass files are in the same location as the other project files.
    I have creatyed and compiled the TPClass package.
    Is there more I need to do?
    Brenton

    I think you are very new to java....
    anyway
    <%@page import="class name with full qualified package name"%>
    like
    <%@page import="com.x1.x2.TPClass"%>
    <%
    TPClass cls =new TPClass();
    //then do whatever you want...
    %>
    hope u understand now.....

  • JAVA PACKAGES and JSP

    i Have two problems one is i am designing a website which consists of a form. I am trying to write the Connectiviy and all other insert statements in seperate java packages and include them in JSP files.
    i Have two java packages one is DBUtil(having two java files both dealing with connectovity) and another one is StudentUtIl which has java files that open the connections with database connection and insert data into DB., I am having a big Problem here. How can i call the function in the other java package in the files in this java package. i have openDB()and Close() in the other Db and i want to call these functions in JAVA classes in the other package. How to include a package. Both these packages are in the same File system mounted on a Local directory

    Thank you for the reply. I am giving the code i have given the full class name . and now it is giving the following error :
    Cannot reference a non-static method connectDB() in a static context.
    I am also giving the code. Please do help me on this. i am a beginner in java.
    import java.sql.*;
    import java.util.*;
    import DButil.*;
    public class StudentManager {
    /** Creates a new instance of StudentManager */
    public StudentManager() {
    Connection conn = null;
    Statement cs = null;
    public Vector getStudent(){
    try{
    dbutil.connectDB();
    String Query = "Select St_Record, St_L_Name, St_F_Name, St_Major, St_Email_Address, St_SSN, Date, St_Company, St_Designation";
    cs = conn.createStatement();
    java.sql.ResultSet rs = cs.executeQuery(Query);
    Vector Studentvector = new Vector();
    while(rs.next()){
    Studentinfo Student = new Studentinfo();
    Student.setSt_Record(rs.getInt("St_Record"));
    Student.setSt_L_Name(rs.getString("St_L_Name"));
    Student.setSt_F_Name(rs.getString("St_F_Name"));
    Student.setSt_Major(rs.getString("St_Major"));
    Student.setSt_Email_Address(rs.getString("St_Email_Address"));
    Student.setSt_Company(rs.getString("St_Company"));
    Student.setSt_Designation(rs.getString("St_Designation"));
    Student.setDate(rs.getInt("Date"));
    Studentvector.add(Student);
    if( cs != null)
    cs.close();
    if( conn != null && !conn.isClosed())
    conn.close();
    return Studentvector;
    }catch(Exception ignore){
    return null;
    }finally {
    dbutil.closeDB();
    import java.sql.*;
    import java.util.*;
    public class dbutil {
    /** Creates a new instance of dbutil */
    public dbutil() {
    Connection conn;
    public void connectDB(){
    conn = ConnectionManager.getConnection();
    public void closeDB(){
    try{
    if(conn != null && !conn.isClosed())
    conn.close();
    }catch(Exception excep){
    The main error is occuring at the following lines connectDB() and closeDB() in the class student manager. The class dbutil is in an another package.with an another file called connectionManager which establishes the connection with DB. The dbutil has the openconnection and close connection methods. I have not yet written the insert statements in StudentManager. PLease do Help me

  • NoClassDefFound error when using custom Java package in scripting QPAC

    Hi,
    I compiled a little Java-package (.jar), which contains a class that uses
    com.adobe.workflow.datatype.form.FormDataTypeInstanceImpl.
    I put my library in the lib folder of JBoss (...\server\all\lib).
    Then I'm was trying to invoke my custom class in the scripting QPAC. But I'm constantly getting the error message
    NoClassDefFound com\adobe\workflow\datatype\form\FormDataTypeInstanceImpl. I already put
    adobe-wkf.jar (and various others) in the lib folder of JBoss. Without ever succeeding. Unfortunately.
    I'm going mad about this.
    Is there a way to address a custom package in the scripting QPAC, which uses
    FormDataTypeInstanceImpl?
    Steve

    Removing the LiceCycle jars from the lib folder did not work. I still get the same error message.
    What I wanted to do is provide some basic utilities, without having to spend a lot of time designing QPAC user interfaces.
    My utility class contains methods like this one:
    @param 
    pFormData
    @return
    @throws 
    ParserConfigurationException
    @throws 
    SAXException
    @throws 
    IOException
    public static 
    org.w3c.dom.Document formToXml
    FormDataTypeInstanceImpl pFormData
    throws 
    ParserConfigurationException, SAXException, IOException 
    byte
    data = pFormData.getXFAData
    InputStream objXMLInputStream = 
    new 
    ByteArrayInputStream
    data
    // create new Document object
    DocumentBuilderFactory objFactory = DocumentBuilderFactory.newInstance
    DocumentBuilder objBuilder = objFactory.newDocumentBuilder
    org.w3c.dom.Document objDocument = objBuilder.parse
    objXMLInputStream
    return 
    objDocument;
    Even without ever invoking the aforementioned method, I get the error
    NoClassDefFound: FormDataTypeInstanceImpl. Which is pretty weird.
    Do I have to write my own classloader?
    Steve

  • How to find classes in a java package

    i am writing a java IDE. i want to extract all class names from a java package eg. java.lang (through coding). how can i do that.
    Thanks in advance

    File file = new File("path to your jar file");
    JarFile jf = new JarFile(file);
    Enumeration e = jf.entries();
    ZipEntry ze = null;
    while(e.hasMoreElements()){
    ze = (ZipEntry) e.nextElement();
    ze.toString(); // gives you the file name
    you have to understand java.util.jar java.util.zip packages for working with jar/zip files.
    Hope this helps

  • How to import java package in form 10g

    hello
    i have make a java package but its not looking so far possible to include it in java import list, how i can import it in form 10 g

    hi,
    if classpath does not work you can try to add your jar file at this registry key :
    HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_DevSuiteHome\FORMS_BUILDER_CLASSPATH
    Engin.

  • Problem with Java-Packages in JavaFX-Scripts

    Hello!
    What I'm trying to do is using a class I've built in my project in a JavaFX-Script, my problem is that the compiler keeps telling me my package wouldn't exist.
    My filestructure is basically the following:
    src
    |-com.foo.java
    |-- MyClass.java
    |-com.foo.javafx
    |-- MyFXScript.fx
    I've tried importing the package or just writing the fully qualified classname when trying to create an instance, the messages didn't differ. I'm not at home right now so I don't remember the exact compiler-message, but it was something like "Package does not exist: com.foo.java".
    Any ideas? :-)
    Kind regards,
    Joshua
    Edited by: gnrx on Jan 12, 2009 5:55 AM

    It works on my system.
    MyClass.java
    package com.foo.java;
    public class MyClass {
        @Override
        public String toString() {
            return "My Class";
    MyFXScript.fx
    package com.foo.javafx;
    import com.foo.java.*;
    var myClass = new MyClass();
    println(myClass);standard-run:
    My Class
    browser-run:
    jws-run:
    midp-run:
    run:
    BUILD SUCCESSFUL (total time: 3 seconds)

  • Java packages and dependency

    When java was being developed, what was the philosophy behind allowing packages to be mutually dependent?

    Hello Steve,
    The Acyclic Dependencies Principle tells us that no cycles should exit in a model depicting the dependencies between packages. From what I can gather this is useful when developing large software systems, as each package becomes a viable work unit for an engineer or small group of engineers to control as a series of releases. If the ADP is not complied with, cycles may exist in the dependencies between packages. If a change is made to one of those packages within a cycle, then an ugly situation develops as the repercussions of the change are looped through the cycle back to its source and so on.
    The thing is though, during my readings I came across a statement that said Java packages were mutually dependent. I was just wanting to know why a language that utilises object oriented technology, left the practice of the ADP up to the descretion of the developer? Is the full implementation of ADP on a software system an ideal world scenario?
    Anders.

  • Java package and c++ header files

    What is the difference between importing java package and including header files in c++?

    I do not know .. have been away from C/C++ for a long time...
    As much as I remember you can only import one header file each time... also when you import a header file you can just call methods from the header file automatically ...
    However I could be very wrong on this .. really lost touch from C/C++ ...
    regards,
    Sim085

  • Error occured while running .java package in BPEL

    Hi All,
    I'm trying to run .java package which is using RIDC components (GET_FILE) option.
    I have set my local IP address in the config.cfg file also and restarted.
    Still i'm getting below error in Jdeveloper when I run the package.....
    oracle.stellent.ridc.protocol.ProtocolException: Unable to initialize connection idc://tgreenspence:4444
    *     at oracle.stellent.ridc.protocol.intradoc.socket.SocketConnectionManager.initializeConnection(SocketConnectionManager.java:35)*
    *     at oracle.stellent.ridc.protocol.intradoc.socket.SocketConnectionManager.initializeConnection(SocketConnectionManager.java:22)*
    *     at oracle.stellent.ridc.protocol.impl.SimpleConnectionPool.acquireConnection(SimpleConnectionPool.java:44)*
    *     at oracle.stellent.ridc.IdcClient.sendRequest(IdcClient.java:151)*
    *     at test.TestRIDC.TestRIDCGetFile.main(TestRIDCGetFile.java:52)*
    Caused by: oracle.stellent.ridc.protocol.ProtocolException: java.net.ConnectException: Connection timed out: connect
    *     at oracle.stellent.ridc.protocol.intradoc.socket.SocketConnection.connect(SocketConnection.java:52)*
    *     at oracle.stellent.ridc.protocol.intradoc.socket.SocketConnectionManager.initializeConnection(SocketConnectionManager.java:33)*
    *     ... 4 more*
    Caused by: java.net.ConnectException: Connection timed out: connect
    *     at java.net.PlainSocketImpl.socketConnect(Native Method)*
    *     at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)*
    *     at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)*
    *     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)*
    *     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)*
    at java.net.Socket.connect(Socket.java:529)
    *     at java.net.Socket.connect(Socket.java:478)*
    *     at java.net.Socket.<init>(Socket.java:375)*
    *     at java.net.Socket.<init>(Socket.java:189)*
    *     at oracle.stellent.ridc.protocol.intradoc.socket.SocketConnection.createSocket(SocketConnection.java:126)*
    *     at oracle.stellent.ridc.protocol.intradoc.socket.SocketConnection.connect(SocketConnection.java:44)*
    *     ... 5 more*
    What will be the solution ??
    Thanks,
    Nir

    take the code out of bpel. run it standalone. does it work?
    -ryan

  • Just Starting out with java packages

    Hello,
    I'm a beginner and I'm starting out with java packages.
    I wrote two simple .java files, one test program and one containing a simple class.
    Both files are compiling without errors but When I run the program I get an error NoClassDeffoundError.
    I use the import <package> statement And I think I'm using the CLASSPATH variable correctly.
    SET CLASSPATH=d:\nopol
    path for the .java containing the test class is:
    d:\nopol\utilities \myapp.
    In the test file I use "import utilities.myapp.*.
    I would be very happy if anyone could help me
    Thanks beforehand
    Nopol.

    The test file should be in d:\nopol, if it's not a part of your package utilities.myapp. Everything should be compiled from d:\nopol, the test class with "javac ClassName.java" and the class in the package with "javac utilities/myapp/ClassName.java".
    Your classpath seems fine for now, though. But yes, do add the period there, otherwise you could run into problems later.

  • Problem finding native methods in java packages

    Hi,
    I have a java class which uses some native methods written in OCamL. I wrote a C file which calls the OCamL code, and created the corresponding shared library using the jni. I then tested my java file and everything works fine, I can nicely call the OCamL functions. However, I need this java file to be included in a package, but whenever I add the line:
    package somepackage;
    on top of the java code, my java file simply doesn't seem to find the C and OCamL implementation anymore :
    javac -cp :./path/of/somepackage
    -Djava.library.path=/full/path/of/somepackage MyProgram args
    Exception in thread "main" java.lang.UnsatisfiedLinkError:functionName
    at somepackage.ClassName.functionName(NativeMethod)
    I have of course put everything (java, C, .h , libsomelibrary.so, and OCamL files) in a directory called somepackage, and written another java file which creates an instance of the first one from outside the package, imports the package, and calls its methods in main(). It just doesn't work anymore.
    I then added a simple hello-world function (not C nor OCamL code) to the java file inside the package. And when invoked from outside, it worked. Question is then... Am I forgetting something to be done, in order to get C and CamL files efectively included in the java package (same as "package somepackage;" in C or OCaml, perhaps)??? Why isn't the java file able to find them inside its very own directory (having into account that without the package definition it worked well)?
    Thanks,
    PS Im using jsdk 1.4.1 on lunyx redhat 8.0

    Did you change the name of the function in the library, too?
    If the function name was
    "Java_YourClass_functionname",
    it should be now
    "Java_path_to_your_package_YourClass_functionname".

  • Use of Java packages in Java stored procedures? (Oracle 10.2)

    Hi all-
    Does Oracle's Java stored procedures support Java packages? In all the examples I've seen, packages are never used, and when I added one to a test file, it compiled it just fine, but referencing the class from the package itself resulted in a compiling error.
    In other words, it seems to make absolutely no difference if I preface my Java class with
    package com.mycompany.whatever;
    and while I can "import com.mycompany.whatever.MyClass" in another Java file, it seems to not care at all whether I do so or not.
    Thanks for any clarification,
    Ilford

    Hi Ilford:
    Sure you can use fully package notation in your Java classes.
    Look at this Java source code:
    http://dbprism.cvs.sourceforge.net/dbprism/cms-2.1/src/com/prism/cms/core/
    All of them are Java Stored procedures.
    Best regards, Marcelo.

  • Java package to parse email

    Hi,
    I was wondering if anyone knows of a java package which does the following. Monitors an email account (could be through SMTP) and downloads email based on certain rules you can mention in the config file. For instance, if the the email comes from address [email protected] then download the attachment B.pdf to a certain folder.

    harsh884 wrote:
    May be you can use Apache common-logging.jar its API for getting logs....try the link below
    http://commons.apache.org/logging/guide.html
    Was that meant to be posted in this thread?

  • Java package compile errors

    I use a batch file to compile a java package. And I got the following errors:
    TabPages: Java: 29: Cannot solve symbol
    Symbol: class JSPFactory
    Location: package JSP
    JSPFactory = javax.Servlet.jsp.JSPFactory.getDefaulfFactory();
    Note: Some input files use or override a deprecated APT.
    Note: Recompile with -deprecation for details.
    I am using New Atlanta servletExec 3.1 and IIS server. Can anyone help me figure our the above errors? Thanks!

    if I add the "set classpath=".,C:/javax" to the begining of the batch file, will this override the classpath that I set in the Environment window? I am worried about this since we have a bunch of environment variables already been set there.
    I tried to add the ";c:\javax" at the end of the classpath on my Environment window, and rebooted the server, but still got the same error message. Did I have some syntax error? What does the dot before ";C:/javax" mean? I deleted it when I added them to the classpath.
    It will cause too much trouble to add the "javac XXX.java -classpath=".;C"/javax" to each file that needs this package because we don't have a single command for compiling a single java file. We have a huge amount of java files and we just use a single "javac -d" to compile every file under several folders. Our batch file is as follows:
    del /F/Q ..\classes
    javac -d ..\classes *.java htmltool\html\*.java ises\*.java DropDown\*.java frmselection\*.java grid\*.java treeView\*.java reportTreeMenu\*.java hs\types\*.java
    del /F ..\lib\grid.jar
    del /F ..\lib\TreeView.jar
    cd ..\classes
    jar cf ..\lib\grid.jar grid
    rmdir /S/Q grid
    jar cf ..\lib\TreeView.jar treeView
    rmdir /S/Q treeView
    cd ..\javasrc
    Another thing is that: we have exact the same classpath and batch file on another server which works fine, and its classpath doesn't include explicitly stuff like";c:\javax", but we never have prolbem compiling the java source. So do I miss something else?

  • Java Package count files

    Hi,
    I have a java package which contains several java classes.
    Package name Util
    Contains lets say 3 Classes but further classes could be added in the future. I need to know how many classes are in this package.
    So im wondering is it possible to a count of the number of classes/files in a package and save this to a variable.

    So im wondering is it possible to a count of the
    number of classes/files in a package and savethis
    to
    a variable.NoWell not easily anyway. You could count the number of
    class files in a given directory or something.
    @lunny,
    I can think of no reason why this would be something
    you would want to do. Could you please give more
    information on why you think this is something you
    want/need to do?Ofcourse.
    I am writing a program that has a different class file for every year so runs different for every year.
    At the start of the program there is a drop down box listing the different years. For every year there is a respective class File. At the moment there is 3 class files / 3 years. Lets say I decided to add another one. I would have to add my 4th class file to my java package but also change my form to display 4 years.
    What I would like to do is before i display the form is pick up the number of java files in package (which would tell me the number of years) and then I can use this to display X number of options in form.

Maybe you are looking for