Concept of package in java???

as far i understood, packages create a namespace.
In the beginning of a java file i say...
package pack;then in some other java file I should be able to say...
import pack.*;am i wrong? by the way both t6he java files are in the same directory. what am i doing wrong. my second program where i import the pack.* does not compile.

To my understanding, the import statement specifies the class path you are going to refer, and the system will look up these packages in the classpath list you set in the system variable. Usually, the current directory is added to the list.
For example, there are two classes A and B, and A is packaged in pack. both A and B are located in the directory pack. When you import pack.A, the system will look for pack/A in the current directory, but there is no such directory pack.
Maybe one solution is to create a new directory pack under pack, and move A under pack/pack. It will look like this
pack/pack/A
pack/BA.java
package pack;
......B.java
import pack.A;
.......Another solution may include ".." in the classpath variable.
Maybe you can try!

Similar Messages

  • Problem with "package-info.java" using EJB 3.0 and OC4J

    Hi all.
    I already posted this question on JDeveloper forum, but didn't get any answer,
    so I'll try posting here.
    Anyway, I'm new both to JDeveloper and J2EE,
    so I'm trying out examples for EJB 3.0, and I got stuck at "Use Security Annotations with EJB 3.0"
    (http://www.oracle.com/technology/tech/java/oc4j/ejb3/howtos-ejb3/howtoejb30security/doc/how-to-ejb30-security-ejb.html).
    Example code is working perfectly, if one builds it using Ant, but I'm importing all examples into JDeveloper (or at least I'm trying to :))
    JDeveloper can't build file "package-info.java" containing following code:
    @javax.annotation.security.SecurityRoles(roleNames={"superuser", "user"})
    package oracle.ejb30;I'm getting following output in "Compiler - Log" window:
    Error(2,1): 'class', 'interface', or 'enum' expected.
    Help much appreciated...
    platform used:
    Windows XP SP2
    JDeveloper Studio (Version 10.1.3, Build 3412)
    JDK 1.5_06
    OC4J 10.1.3 developer preview 4 (standalone version)

    Since you're using EJBs, you can use JTA and can skip the getTransaction() calls. If you want to use getTransaction().begin() and commit(), then make sure that your EntityManager is resource-local. The configuration for this is in persistence.xml. Set a transaction-type of RESOURCE_LOCAL rather than JTA.

  • How to import DBMS_LOB package in java

    hi
    how we can use pl/sql's package in java
    any body can help me
    where i can found harachy of DBMS_LOB package
    to include in my java or jsp program
    thanx

    perhaps this topic can help :
    Calling PL/SQL from Java
    and the use of DBMS_LOB package is here:
    Supplied PL/SQL Packages and Types Reference Contents / Search / Index / PDF
    http://download-east.oracle.com/docs/cd/B10501_01/appdev.920/a96612.pdf
    Java Stored Procedures Developer's Guide Contents / Search / Index / PDF
    http://otn.oracle.com/pls/db92/db92.docindex?remark=homepage
    I hope that can help you. Perhaps another person can give the excat code.
    Good luck!
    Joel P�rez

  • XML without namespace and prefix, modified package-info.java, JAX-WS option

    Hello
    I have created a consumer business service which will be called from JDEdwards EOne, pulls data from database and send it to Fusion Middleware.
    SO, I have created proxy using JAX-WS option. And suggested in oracle doc, I created proxy outside OMW and then copied it to my project. XML payload is getting generated without namespace and prefix. After some research, I modified package-info.java. Now, I am able to send the payload and if test it locally from Jdeveloper and take xml output using marshaller I can see it has namespace and prefix as well. BUt, when I run this from server it does not have namespace and prefix.
    Please help.
    Thanks
    TK

    Just to clerify,
    The common complex types are StatusInfo, IdcProperty and IdcPropertyList. I ahve 3 more WSDL's with the exact same entires for those 3.

  • Packages in Java

    Hi Guys,
    I'm new in java world, and I have some questions, if anybody can help me plz.
    1- The packages in java such java.sql and so on where we can downlad it?
    2- How to add these packages to work with java?
    Thanks

    The following packages are already bundled with the jdk or jre you downloaded and installed:
    java.applet
    java.awt
    java.awt.color
    java.awt.datatransfer
    java.awt.dnd
    java.awt.event
    java.awt.font
    java.awt.geom
    java.awt.im
    java.awt.im.spi
    java.awt.image
    java.awt.image.renderable
    java.awt.print
    java.beans
    java.beans.beancontext
    java.io
    java.lang
    java.lang.annotation
    java.lang.instrument
    java.lang.management
    java.lang.ref
    java.lang.reflect
    java.math
    java.net
    java.nio
    java.nio.channels
    java.nio.channels.spi
    java.nio.charset
    java.nio.charset.spi
    java.rmi
    java.rmi.activation
    java.rmi.dgc
    java.rmi.registry
    java.rmi.server
    java.security
    java.security.acl
    java.security.cert
    java.security.interfaces
    java.security.spec
    java.sql
    java.text
    java.text.spi
    java.util
    java.util.concurrent
    java.util.concurrent.atomic
    java.util.concurrent.locks
    java.util.jar
    java.util.logging
    java.util.prefs
    java.util.regex
    java.util.spi
    java.util.zip
    javax.accessibility
    javax.activation
    javax.activity
    javax.annotation
    javax.annotation.processing
    javax.crypto
    javax.crypto.interfaces
    javax.crypto.spec
    javax.imageio
    javax.imageio.event
    javax.imageio.metadata
    javax.imageio.plugins.bmp
    javax.imageio.plugins.jpeg
    javax.imageio.spi
    javax.imageio.stream
    javax.jws
    javax.jws.soap
    javax.lang.model
    javax.lang.model.element
    javax.lang.model.type
    javax.lang.model.util
    javax.management
    javax.management.loading
    javax.management.modelmbean
    javax.management.monitor
    javax.management.openmbean
    javax.management.relation
    javax.management.remote
    javax.management.remote.rmi
    javax.management.timer
    javax.naming
    javax.naming.directory
    javax.naming.event
    javax.naming.ldap
    javax.naming.spi
    javax.net
    javax.net.ssl
    javax.print
    javax.print.attribute
    javax.print.attribute.standard
    javax.print.event
    javax.rmi
    javax.rmi.CORBA
    javax.rmi.ssl
    javax.script
    javax.security.auth
    javax.security.auth.callback
    javax.security.auth.kerberos
    javax.security.auth.login
    javax.security.auth.spi
    javax.security.auth.x500
    javax.security.cert
    javax.security.sasl
    javax.sound.midi
    javax.sound.midi.spi
    javax.sound.sampled
    javax.sound.sampled.spi
    javax.sql
    javax.sql.rowset
    javax.sql.rowset.serial
    javax.sql.rowset.spi
    javax.swing
    javax.swing.border
    javax.swing.colorchooser
    javax.swing.event
    javax.swing.filechooser
    javax.swing.plaf
    javax.swing.plaf.basic
    javax.swing.plaf.metal
    javax.swing.plaf.multi
    javax.swing.plaf.synth
    javax.swing.table
    javax.swing.text
    javax.swing.text.html
    javax.swing.text.html.parser
    javax.swing.text.rtf
    javax.swing.tree
    javax.swing.undo
    javax.tools
    javax.transaction
    javax.transaction.xa
    javax.xml
    javax.xml.bind
    javax.xml.bind.annotation
    javax.xml.bind.annotation.adapters
    javax.xml.bind.attachment
    javax.xml.bind.helpers
    javax.xml.bind.util
    javax.xml.crypto
    javax.xml.crypto.dom
    javax.xml.crypto.dsig
    javax.xml.crypto.dsig.dom
    javax.xml.crypto.dsig.keyinfo
    javax.xml.crypto.dsig.spec
    javax.xml.datatype
    javax.xml.namespace
    javax.xml.parsers
    javax.xml.soap
    javax.xml.stream
    javax.xml.stream.events
    javax.xml.stream.util
    javax.xml.transform
    javax.xml.transform.dom
    javax.xml.transform.sax
    javax.xml.transform.stax
    javax.xml.transform.stream
    javax.xml.validation
    javax.xml.ws
    javax.xml.ws.handler
    javax.xml.ws.handler.soap
    javax.xml.ws.http
    javax.xml.ws.soap
    javax.xml.ws.spi
    javax.xml.xpath
    org.ietf.jgss
    org.omg.CORBA
    org.omg.CORBA_2_3
    org.omg.CORBA_2_3.portable
    org.omg.CORBA.DynAnyPackage
    org.omg.CORBA.ORBPackage
    org.omg.CORBA.portable
    org.omg.CORBA.TypeCodePackage
    org.omg.CosNaming
    org.omg.CosNaming.NamingContextExtPackage
    org.omg.CosNaming.NamingContextPackage
    org.omg.Dynamic
    org.omg.DynamicAny
    org.omg.DynamicAny.DynAnyFactoryPackage
    org.omg.DynamicAny.DynAnyPackage
    org.omg.IOP
    org.omg.IOP.CodecFactoryPackage
    org.omg.IOP.CodecPackage
    org.omg.Messaging
    org.omg.PortableInterceptor
    org.omg.PortableInterceptor.ORBInitInfoPackage
    org.omg.PortableServer
    org.omg.PortableServer.CurrentPackage
    org.omg.PortableServer.POAManagerPackage
    org.omg.PortableServer.POAPackage
    org.omg.PortableServer.portable
    org.omg.PortableServer.ServantLocatorPackage
    org.omg.SendingContext
    org.omg.stub.java.rmi
    org.w3c.dom
    org.w3c.dom.bootstrap
    org.w3c.dom.events
    org.w3c.dom.ls
    org.xml.sax
    org.xml.sax.ext
    org.xml.sax.helpers
    kind regards,
    Jos

  • [svn:bz-trunk] 10059: update two package-info.java files, and add one new one.

    Revision: 10059
    Author:   [email protected]
    Date:     2009-09-08 11:31:48 -0700 (Tue, 08 Sep 2009)
    Log Message:
    update two package-info.java files, and add one new one.
    Modified Paths:
        blazeds/trunk/modules/proxy/src/flex/messaging/services/http/proxy/package-info.java
    Added Paths:
        blazeds/trunk/modules/core/src/flex/messaging/util/concurrent/package-info.java
        blazeds/trunk/modules/core/src/flex/messaging/validators/package-info.java

    Revision: 10059
    Author:   [email protected]
    Date:     2009-09-08 11:31:48 -0700 (Tue, 08 Sep 2009)
    Log Message:
    update two package-info.java files, and add one new one.
    Modified Paths:
        blazeds/trunk/modules/proxy/src/flex/messaging/services/http/proxy/package-info.java
    Added Paths:
        blazeds/trunk/modules/core/src/flex/messaging/util/concurrent/package-info.java
        blazeds/trunk/modules/core/src/flex/messaging/validators/package-info.java

  • Calling SQL packages from java

    How do I call ORACLE sql packages from java?
    We are still using Oracle 7.3. Any sample code
    would be appreciated.

    utility.processPLSQL( connRisk,
    " Begin "
    + " hvar_sum.p_load_var_summary_data("
    + " '" + dfCall.format( priceDate ) + "', "
    + " '" + promptMonth + "',"
    + daysBack + ","
    + aliasType + ","
    + "'" + connRisk.owner + "'"
    + "); "
    + " end ; ",
    "Load VaR Summary Data",
    utility.noLogMsg ) ;
    public boolean processPLSQL(
    MyConnection conn,
    String sql,
    String dataType,
    boolean createLogMessage ) {
    double startTime = conn.log.getStartTime() ;
    try {
    CallableStatement cs = conn.theConnection.prepareCall(sql);
    cs.execute() ;
    cs.close() ;
    conn.theConnection.commit();
    if ( createLogMessage ) conn.log.logTiming( dataType, startTime ) ;
    } catch ( SQLException e ) {
    conn.log.logError( "Utility.processPLSQL; SQLException Error: " + e ) ;
    System.out.println(new java.util.Date().toString() + "; User: " + conn.user
    + "; SQL: " + sql );
    return false ;
    return true ;
    }

  • Prohibited package name: java.sql

    hi,
    i am trying to push a java application onto a JRun 3.1 server connecting to a oracle 8 database. in my servlet initialization, i use a connection pool to gain a connection to the database.
    Class.forName("oracle.jdbc.OracleDriver");
    outConn = DriverManager.getConnection(outUrl, outUsername, outPassword);
    //throws error at the above line
    this will throw an error:
    java.lang.SecurityException: Prohibited package name: java.sql
    this error is most peculiar because it runs fine locally on my developers version of JRun 3.1. but when i push it to a licensed version on a different server it gives this error. any hints?

    I believe that class name for the Oracle JDBC driver is oracle.jdbc.driver.OracleDriver. The one you posted is incorrect.

  • Creating package-info.java in Netbeans

    I'm a little frustrated that Netbeans won't even let you create a 'package-info.java' file because of its naming rules. Is there any way to get around this?

    I don't know NetBeans very well, so don't know of any workaround for the naming.
    You can just name the file "package.html" and it will do the same thing. The drawback is that it won't allow for package annotations -- it can still have javadoc tags, though.
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#packagecomment

  • Packages that java normally already imports

    I am trying to get back into programming, and I remember awhile ago being told that java automatically imports certain packages, like java.lang, and maybe a couple more. I tried to test that out by using methods withing java.lang, or java.util, or java.io without importing those packages.
    So I tried to test out java.util. I created an Arrays class without explicitly importing java.util. But my programming didn't recognize the class. I think it is possible that because of my directory structure the imports isn't working. But I'm not exactly sure how to make java see the packages in it's correct directory. Anybody can help? A more extensive question...what kind of environment does everybody use to code (windows environments please, that's what I'm using, I haven't set up a Linux box yet).

    I am trying to get back into programming, and I
    remember awhile ago being told that java automatically
    imports certain packages, like java.lang, and maybe a
    couple more. I tried to test that out by using
    methods withing java.lang, or java.util, or java.io
    without importing those packages.
    So I tried to test out java.util. I created an Arrays
    class without explicitly importing java.util. But my
    programming didn't recognize the class. I think it is
    possible that because of my directory structure the
    imports isn't working. But I'm not exactly sure how
    to make java see the packages in it's correct
    directory. Anybody can help? A more extensive
    question...what kind of environment does everybody use
    to code (windows environments please, that's what I'm
    using, I haven't set up a Linux box yet).Only the public classes in the package java.lang are automatically imported. Here is some more information about packages from Sun's java tutorial:
    http://java.sun.com/docs/books/tutorial/java/interpack/packages.html

  • How many package in Java 1.1?

    Do you know, How many package in Java 1.1?

    Idiotic question, so here's an idiotic reply:
    jar tf /path/to/java/lib/rt.jar |\
       egrep -v '^(META-INF|com/sun|sun)' |\
       sed -e 's/\/[^/]*$//' |\
       sort -u |\
       sed -e 's;/;.;g' |\
       wc -lAnd if you change the last wc -l to more, you'll see the actual package names.

  • Registering package in java??

    heloo guys!
    How to register a package in java???
    Your post is greatly appreciated....
    -=samer=-

    I mean i have download a jama package..there should be documentation available with instructions.
    there should be a library that is a .jar file
    your application needs to know where this .jar file is.
    you tell it where it is by specifying the classpath.
    you should know where this jar file is located
    make sure it can be seen by specifying the classpath

  • Voronoi package in java

    hi all,
    Can any body suggest me a robust voronoi package in java. I already tried compuational geometry package which has some bugs in the generation of voronoi diagram.
    Thanks in advance
    - Ravi Setti

    i needed to decompile something and modified it, now i need to compile it backDo you have permission for that?
    db

  • IOException: Prohibited package name: java.lang

    Hi!
    I have problems when trying to call a method that throws an exception over RMI-iiop. Instead of the exceptions that should be thrown I get an IOException and a stackTrace is printed out in the console(even if the exception is caught) The server is WL8.1 SP3 with java 1.4.2 and the client runs under java 1.3.1_09-b03.
    It works when the client runs under java 1.4.2. I also wrote a small testapplication outside of WL and it works fine too(using RMI-iiop, tnameserv and suns ORB, server under java 1.4.2 and client under java 1.3.1_09-b03).
    But when trying to call the method in WL i get the exception below instead of the one that is thrown.
    java.io.IOException: Prohibited package name: java.lang
         at com.sun.corba.se.internal.io.IIOPInputStream.throwExceptionType(Native Method)
         at com.sun.corba.se.internal.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:272)
         at com.sun.corba.se.internal.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:245)     at com.sun.corba.se.internal.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:207)
         at com.sun.corba.se.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:1058)
    I have also tried to use suns ORB in WL but still get the same problem. Everything works fine except when an exception is thrown by the remote method.
    Any ideas what the problem could be?

    Hi, thank you for the answer.
    But I still think it can be a WL-problem. I can get an application outside of WL to work between java 1.4.2 and java 1.3.1. Even when sending a new exception created and compiled under 1.4.2 and sent to the 1.3.1-JVM, it is recieved correctly by the 1.3.1-JVM and thrown.
    I also tried to change WL to use SUNs ORB which I use in my test but still get the same problem so it feels like the problem is with WL's JNDI..
    /Jonas
    Jonas Mohlin <[email protected]> writes:
    Well the problem is because of the change in format
    java.lang.Throwable in
    J2SE 1.4. There are known bugs in the Sun 1.3.1 ORBs
    that prevent this
    working with a vanilla 1.3.1 client - and we can only
    support a WLS IIOP
    client running with 1.3.1 in this scenario (e.g. WLS
    7.0).
    andy
    Hi!
    I have problems when trying to call a method thatthrows an exception over RMI-iiop. Instead of the
    exceptions that should be thrown I get an IOException
    and a stackTrace is printed out in the console(even
    if the exception is caught) The server is WL8.1 SP3
    with java 1.4.2 and the client runs under java
    1.3.1_09-b03.
    It works when the client runs under java 1.4.2. Ialso wrote a small testapplication outside of WL and
    it works fine too(using RMI-iiop, tnameserv and suns
    ORB, server under java 1.4.2 and client under java
    1.3.1_09-b03).
    But when trying to call the method in WL i get theexception below instead of the one that is thrown.
    java.io.IOException: Prohibited package name:java.lang
         atcom.sun.corba.se.internal.io.IIOPInputStream.throwExce
    ptionType(Native Method)
         atcom.sun.corba.se.internal.io.IIOPInputStream.simpleRea
    dObject(IIOPInputStream.java:272)
         atcom.sun.corba.se.internal.io.ValueHandlerImpl.readValu
    eInternal(ValueHandlerImpl.java:245)     at
    com.sun.corba.se.internal.io.ValueHandlerImpl.readValu
    e(ValueHandlerImpl.java:207)
         atcom.sun.corba.se.internal.iiop.CDRInputStream.read_val
    ue(CDRInputStream.java:1058)
    I have also tried to use suns ORB in WL but stillget the same problem. Everything works fine except
    when an exception is thrown by the remote method.
    Any ideas what the problem could be?--

  • Packaging a Java Application?

    Is there a quick and easy way to package a java program up into something (like an EXE file) and run, like a C program? Or does any user have to first compile and then run in the java Compiler?

    Compile your code, ending up with a bunch of classes. Put them in a jar file with "Main-class:" defined (I believe; check the docs first).
    Then any user who has set up their system to use javaw to execute jars, can just double-click on your jar to run it.
    BTW, you don't run code in the compiler. You compile with the compiler. You run with a JVM.

Maybe you are looking for

  • Iphone restoring PROBLEM PLEASE HELP! HANK U!

    My ITunes not restoring my IPhone, it stuck on Restoring iPhone Softwear, I was trying to downgrade my iPhone softwear and did something to the hosts file and after that  my iTunes would not let me Restoring my IPHONE Please HELP Thank U

  • HT201302 I can't find my photos or videos on my pc after downloading from my iphone

    Hi Everyone I'm not good with technology so apologise now if this is a topic which has already been answered here.  I've recently bought and have started using the iphone, and am loving the whole capturing video footage etc.  I've synced to my laptop

  • Extended classic scenario PO not created

    Hi Guys, Hope someone could give me some hints on this. This is an isolated case.System works fine for all other shopping cart except for below case. The shopping cart approved and suppose to create the PO. I could see the PO number generated in BBP_

  • Margin Between two SpanElements in single ParagraphElement

    Hi      I m creating an application using TextLayout Framework in FlexBuilder3(Sdk3.4). Code is like           var paragraphElement:ParagraphElement= new  ParagraphElement();           var spanElement1:SpanElement= new SpanElement():           spanEl

  • My MSWord .docx download as docx.exe

    Just recently, any MS Word .docx download as docx.exe and I can't open them. .doc open normally.  I can rename the file in Downloads as .docx but would like to find a way to eliminate the download as .docx.exe. Any ideas...?