How to refer to root class from a package in Java 1.4

Hi
I have written a class at root level and it is being called be a different class which is defined in a package, when I am trying to import base class it is giving compilation error in Java 1.4.0 and Java 1.4.1 version but code work fine with java 1.2.2
For you reference here is sample code
First class AddNumbers defined at root
public class AddNumbers{
     int iResult=0;
     public AddNumbers(int a, int b){
          iResult= a+b;
     public int getSum(){
          return iResult;
second class PlayNumbers is defined in package TreeTest
package TreeTest;
import AddNumbers;
public class PlayNumbers{
     int iNum1 =5;
     int iNum2 = 10;
     int iRes;
     public PlayNumbers(){
          AddNumbers ad = new AddNumbers(iNum1,iNum2);
          iRes = ad.getSum();
          System.out.println("Result is ="+iRes);
public static void main(String [] arg){
          new PlayNumbers();
Could anyone suggest how to invoke AddNumbers class in JDK1.4.1
Thanks
AKM

The root package should never have been automatically included for compilation purposes.
In order to access a class in the root package import it as you should for any other class.
import AddNumbers;
is the proper way to do this.
The only time you don't need to use an import statement is if the class you wish to reference is in the same package as the class that refers to it. Again, you should really import such classes as it makes things explicitly clear which classes you are referring to.

Similar Messages

  • How to Change the Development Class from $TMP to YABAP in Layout

    Hi all,
    How to Change the Development Class from $TMP to YABAP in Layout( SE71).
    Thanks & Regards,
    N.L.Narayana

    Hi,
    it is possible with SE03. you just click on Change <b>Object Directory Entries</b> under the tree menu <b>Object directory</b>, and then enter in the last column of table control
    Check the check box and enter FORM and formname,
      R3TR FORM SAPscript form 
    then execute it.
    then you will be able to change it to PACKAGE from $TMP
    regards
    vijay

  • Question about access non-public class from other package.

    Hi, everyone!
    Suppose class A and class B are in the same java file of package pkg1
    -- A.java. So, A is a public class and B is a non-public class.
    If I want to access class B from another class class C and class
    C is in package pkg2. When compiling, an error occurs indicating
    that class B is not visible to class C.
    So, If I defined serveral classes in one java file and I want to
    access every class from other package. How should I do?
    (I think in one java file, there should be only one public class and
    only the public class can be accessed from other package.)
    Thanks in advance,
    George

    So, If I defined serveral classes in one java file and
    I want to
    access every class from other package. How should I
    do? As you already seem to know, there is at most one public class allowed per source file (at least, with javac and most popular compilers). So if you want more than one public class, you will need to use more than one file...

  • How to search for available class in given package?

    How to search for available class in given package or sub package?

    Finally i did it. I make hibernate and spring without much configuration. I just pass the package pattern to search for all bean. I named it package pattern injection.
    My website is still under construction yet. It named Jimmy6 Framework.
    The code it just the following for all hibernate and spring bean for the whole project.
    <bean id="sessionFactory" class="com.j6.framework.JAnnotationSessionFactoryBean">
              <property name="annotatationOrHbmXmlPackagePattern">
                   <list>
                        <value>com\.j6\.project.+?\.vo\..+?</value>                    
                   </list>
              </property>               
    <bean id="autoBeanCreatorFactoryManager" class="com.j6.framework.resource.AutoBeanCreatorFactory">
              <property name="packagePatterns">
                   <list>
                        <value>com\.j6\.project\..+?\.manager\..+?</value>
                   </list>
              </property>
         </bean>
         <bean id="autoBeanCreatorFactoryDao" class="com.j6.framework.resource.AutoBeanCreatorFactory">
              <property name="packagePatterns">
                   <list>
                        <value>com\.j6\.project\..+?\.dao\.hibernate.+?</value>
                   </list>
              </property>
         </bean>Feel free to have a look and gv some comments. Thanks :)
    Regards,
    Jimmy6
    Edited by: jimmy6 on Nov 4, 2008 8:15 AM

  • How to refer to enclosing instance from within the member class?

    Hi
    How to refer to the enclosing instance from within the member class?
    I have the following code :
    import java.awt.*;
    import java.awt.event.*;
    public class MyDialog extends Dialog
         public MyDialog(Frame fr,boolean modal)
              super(fr,modal);
              addWindowListener(new MyWindowAdapter());
         public void paint(Graphics g)
              g.drawString("Modal Dialogs are sometimes needed...",10,10);
         class MyWindowAdapter extends WindowAdapter
              public void windowClosing(WindowEvent evt)
                   //MyDialog.close(); // is this right?
    In the above code, how can I call the "close()" method of the "Dialog" class (which is the enclosing class) from the inner class?
    Thanks in advance.
    Senthil.

    Hi Senthil,
    You can directly call the outer class method. Otherwise use the following way MyDialog.this.close(); (But there is no close() method in Dialog!!)
    If this is not you expected, give me more details about problem.
    (Siva E.)

  • How to refer to another EJB from different root

    Hi ,
    Is there any way in JDeveloper to refer to EJB's from another context root ( Technically different application ) from the EJB's in the current context root. ? Am seeing a couple of ways, but looking for something better if possible
    1) Reuse the source code from the other application
    2) Define the other EJB as a Service, use a Service lookup to get the business intent of the service.
    Please advice !!

    Done.

  • How to refer the parent class object from an inner class

    Hi,
    I have a class X, which contains an inner private class Y. Class X has a method getY which returns an object of class Y. Class Y has a method getParent. I want to return the object of parent class from this. The code is like this:
    public inerface IY;
    public class X {
    private class Y implements IY {
    public getParent {
    // ... return the object of parent class which created the object of this inner class
    public IY getY() {
    return new Y();
    Can somebody help me with this...

    interface IY {
    public class X {
        private class Y
            implements IY {
            private X parent;
            public Y(X x)
                parent = x;
            public X getParent()
                // ... return the object of parent class which created the object of this inner class
                return parent;
        public IY getY()
            return new Y(this);
    }Filip

  • How to refer to JNDI PROVIDER_URL from within Tomcat Web app

    Can anyone provide a clear description on how to refer to a "Provider_URL" relative to the web application root for which a Java Class resides within? My issue is as follows. I've looked through the JNDI tutorial and the Tomcat JNDI How-To's and I'm still unable to find a solution.
    I'll elaborate:
    I have a "PROVIDER_URL" class variable defined as:
    private String PROVIDER_URL = "file:/C:/development/MyProject/MyWebApplication/WEB-INF/properties";I initialize my JNDI context within the class:
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
    properties.setProperty(Context.PROVIDER_URL, PROVIDER_URL);
    context = new InitialContext(properties);
    cpds = (ConnectionPoolDataSource) context.lookup(baseName);
    ...The above example works fine. My question is given my web app's directory, how do I refer to "MyWebApplication/WEB-INF/properties" in a relative manner so that if I move my web application to a different server, the directory path does not affect my deployment and I dont have to hardcode the current path? Does this need to occur in the "server.xml" file? Can you provide a URL to an example?
    Your suggestions are appreciated...thanks.

    try to give
    http://localhost:8080
    or the app server based port address.

  • How to refer a base class action directly

    Hi ,
    I have a jsp associated to controller b which extends controller a.
    There is an action in controller a.
    From the jsp it self(With out coming to the controller b ) can i refer an action in controller A.

    Hi,
    You can achieve this via Workshop 9.2 by using the exported Ant script for your project as follows:
    -Ensure that all Jars needed to resolve com.bea.p13n.property.EntityPropertyManager (this particular class is found in weblogic92/common/p13n/lib/p13n_ejb.jar) and all referenced classes are added to the Java build path for your WebLogic EJB project (Properties->Java Build Path->Libraries)
    -Export the "Workshop Ant Script" for your WebLogic EJB project (File->Export->Workshop Ant Script); this will generate a "build.xml" Ant script under your project root directory.
    -Edit this default build script as follows: in the call to the "ejbgen" task within the "build" target, add the attribute: propertyFile="ejbgen.properties"
    -Create a file "ejbgen.properties" under the root of your WebLogic EJB project and add the following entry:
    YourSessionBeanClassName.remote.baseClass=com.bea.p13n.property.EntityPropertyManager
    -Add a "<path refid="java.classpath"/>" within the "<classpath>" for the "java" task element that calls "weblogic.ejbc" (this will ensure that the p13n classes are resolved by EJBC)
    Follow the instructions for executing the Ant build script found here: http://edocs.bea.com/workshop/docs92/ws_platform/ideuserguide/conUseCustomAntBuild.html
    For more information on the EJBGen property file support, see: http://e-docs.bea.com/wls/docs92/ejb/EJBGen_reference.html

  • How Do I Run A Class From Another Class?

    Hiya everyone, id like to know how to run a class from another class.
    Ive got a Login class which extends a JFrame and a Personnel class which also extends a JFrame. When i press the login button (in Login class), ive got it to decide if password/login are acceptable and if they are, I want the Login class to close then run the Personnel class.
    Im just after the code which says to close this class and run the Personnel class. How do i do that?
    Ive researched this but couldnt get an understandable answer!
    Help would be much appreciated, Ant...

    This is the Login Class:
    public class MainMenu extends javax.swing.JFrame {
        Statement statement = null;
        int currentRecord;
        ResultSet rs = null;
        String name = null, job = null, mission = null, login = null, password = null;
        String loginVal;
        String passwordVal;
        /** Creates new form MainMenu */
        public MainMenu() {
            initComponents();
            try{
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String filename = System.getProperty("user.dir") + "/src/Personnel.mdb";
                String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + filename;
                Connection conn = DriverManager.getConnection( database , "","");
                statement = conn.createStatement();
                System.out.println("Connected...ok");
            } catch (Exception e) {
                System.err.println("Got a connection Problem!");
                System.err.println(e.getMessage());
        private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {                                        
            loginVal = txtLogin.getText();
            passwordVal = txtPassword.getText();
            String name = null, job = null, mission = null, login = null, password = null;
            try{
                rs = statement.executeQuery("SELECT Login,Password FROM Personnel WHERE Login = '" + loginVal + "' ");
                System.out.println("TRYING SELECT CLAUSE");
                if(rs.next()){
                    System.out.println("THERE IS A NEXT RECORD");
                    login = rs.getString(1);
                    password = rs.getString(2);
                    System.out.println("GOT THE NEXT RECORD");
                    System.out.println(login + password);
                System.out.println("Query Complete");
            }catch(Exception s){
                //s.printStackTrace();
                System.out.println("NO RECORDS EXIST FOR THIS LOGIN ID");
            if(passwordVal.equals(password)){
                System.out.println("Access Granted"); //CLOSE MAIN AND RUN CONTROL CLASS
            } else{
                System.out.println("Access Denied"); //RE-RUN CLASS
        }                 

  • How does EF Distinguish Regular Classes from Entity Classes?

    I'm newbie to EF, just read a couple of short articles on it the other day.  When reading them I didn't pick up on what criteria EF has for distinguishing regular classes from EF classes. Suppose for instance I wrote up a class for internal use only
    (but which happened to have the same name as one of my Sql Server tables).  Aside from reading my mind, how would EF know that I never intended this class for entity purposes?

    What are you talking about here? It's back to the namespaces.
    If you are making folders in a VS project, then that's a namespace. You crate a class in that namespace, then it should be decelerated with a namespace attribute specifying what namespace the class is in, and you woud have to use an Imports in VB or a Using
    statement in C# pointing to the namesapce where the class is located in the class that needs to use a class in another namespace. Or you don't use Import or Using and you give the full namespace path to the class in code of namespace.classname.The below DB
    first, only a part of the code in  namespace, the usage was installed into the DAL.Model namespace where I have a project called DAL and within the DAL  project I made a folder, a namespace,  named Model and pointed EF to that folder in doing
    an add of a new Item in VS. And everything about EF is in the DAL.MODEL namespace. You can have Jal2 class in the namespace and Jal2 in some other namespace. Ef could care less about Jal2 in the other not DAL.Model namespace.
    I don't care how you do it. I don't care if you are using EF DB first, Model first, Code first,  any other kind of first or you start making your own classes for data yourself, but you need to understand Namespaces in .NET, what they are for,and how
    to use them effectively in creating  .NET solutions. 
    Comon man, this is .NET 101 you should have figured out long ago.
    https://msdn.microsoft.com/en-us/library/ms973231.aspx#assenamesp_topic5
    using System;
    using System.Data.Objects;
    using System.Data.Objects.DataClasses;
    using System.Data.EntityClient;
    using System.ComponentModel;
    using System.Xml.Serialization;
    using System.Runtime.Serialization;
    [assembly: EdmSchemaAttribute()]
    #region EDM Relationship Metadata
    [assembly: EdmRelationshipAttribute("PublishingCompanyModel", "FK_Article_Author", "Author", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(DAL.Model.Author), "Article", System.Data.Metadata.Edm.RelationshipMultiplicity.Many,
    typeof(DAL.Model.Article), true)]
    [assembly: EdmRelationshipAttribute("PublishingCompanyModel", "FK_Payroll_Author", "Author", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(DAL.Model.Author), "Payroll", System.Data.Metadata.Edm.RelationshipMultiplicity.Many,
    typeof(DAL.Model.Payroll), true)]
    #endregion
    namespace DAL.Model
        #region Contexts
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public partial class PublishingCompanyEntities : ObjectContext
            #region Constructors
            /// <summary>
            /// Initializes a new PublishingCompanyEntities object using the connection string found in the 'PublishingCompanyEntities' section of the application configuration file.
            /// </summary>
            public PublishingCompanyEntities() : base("name=PublishingCompanyEntities", "PublishingCompanyEntities")
                this.ContextOptions.LazyLoadingEnabled = true;
                OnContextCreated();

  • How to import a class from a package at the same level

    Hello friends,
    i have a class as Plaf.java
    as
    package org.vaibhav.swing.plaf;
    import java.awt.*;
    import javax.swing.*;
    public class Plaf {
    other code
    }as you see, this is in org.vaibhav.swing.plaf package.
    I have one more class as
    package org.vaibhav.swing.frames;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class StartFrame extends JFrame implements ActionListener {
    other code
    }and this class is in package org.vaibhav.swing.frames
    Please hlp me how to use the class Plaf in StartFrame.java. Rather what import statement should i use in StartFrame.java.
    please help.
    thank you
    Message was edited by:
    vaibhavpingle

    but it then gives me this error
    StartFrame.java:11: package org.vaibhav.swing.plaf
    does not exist
    import org.vaibhav.swing.plaf.*;
    Have you first compiled Plaf.java and saved it in this directory strucuture
    /org/vaibhav/swing/plaf/
    And also have you set your classpath to the parent directory of org folder.
    Message was edited by:
    qUesT_foR_knOwLeDge

  • How to return a list of class from a package

    Hi,
    I'm trying to create a RPG game with 50 characters. There will be a superclass, and each character is a subclass that extends from the superclass. Each will have unique abilities that will be functions. These classes will be thrown into a package.
    I would like to know the code for returning the list of classes in that package. That way, I can present them as a list for the player to choose just a handful of characters to start out with.
    Thanks in advance         

    Hi u can use the this class
    flash.utils.describeType;
    Regards
    Sumit Agrawal

  • How to remove a static class from the Runtime of the JVM

    I want to remove a static class from the Runtime of the JVM.
    My goal is to clear the cache of the "InetAddress.getByName(String host)" static method.
    Thanks in advance.
    Floweb

    Sorry, It means a class that has been loaded in the JVM by the call to a static method......
    Floweb

  • How to extend JAXB genrated classes from other application specifc classes

    Hi,
    I would like to know, is there a way to extend JAXB genrated classes from my application specific classes?
    Thanks!

    extend JAXB genrated classes from my application specific classes
    In JAXB 2.0 a Java class may be mapped to an XML document or an XML Schema with annotations in the javax.xml.bind.annotation package.

Maybe you are looking for

  • Time-out issue Always on SQL 2012 Cluster

    Currently I'm working on a large deployment of a SharePoint 2013 environment (stretched farm over 2 DC's). We are using a SQL 2012 alwayson multisubnet cluster (each DC has 1 SQL node). During the installation of SharePoint we encountered several con

  • I Can't separate text in frames from repeating

    CS4 Flash Pro v:10.0.2 Win 7 Pro I have been working on a Flash site for a while - and learning quite a bit over the past 2 years.  This is my first Flash design website and I can't see where I went wrong. At some point last year I removed subsequent

  • Toggle between Chart and Table

    Hi there ANybody know what I need to do in order to get the function SAPBCTToggleChartTable() function to work? In the standard template, if data is viewed in a graph, an option appears to view the data for that graph in table format. We would like t

  • Issue with extending HzPuiDQMSrchResultsVO

    Hey all, I have a requirement to alter the order by statement in HzPuiDQMSrchResultsVO from "ORDER BY SCORE DESC" to "ORDER BY SCORE DESC, PARTY_NUMBER". I was able to create a new VO by extending the seeded oracle.apps.ar.hz.components.search.server

  • Report Painter-To Bold a Text

    Hi,   Can we make a Text as Bold in Report Painters I have tried with formatting through colours but it is not working. Can anyone guide me. Regards Sunil