About System class

I want to get more deeper with java and i chose the System as my begining. when i saw
private static InputStream nullInputStream() throws NullPointerException {
     if (currentTimeMillis() > 0)
         return null;
     throw new NullPointerException();
    }and the method
     * Returns the current time in milliseconds.  Note that
     * while the unit of time of the return value is a millisecond,
     * the granularity of the value depends on the underlying
     * operating system and may be larger.  For example, many
     * operating systems measure time in units of tens of
     * milliseconds.
     * <p> See the description of the class <code>Date</code> for
     * a discussion of slight discrepancies that may arise between
     * "computer time" and coordinated universal time (UTC).
     * @return  the difference, measured in milliseconds, between
     *          the current time and midnight, January 1, 1970 UTC.
     * @see     java.util.Date
    public static native long currentTimeMillis();i totally confusing. why do things like this.
thanks for any help!!

this is the per code of it
     * The "standard" input stream. This stream is already
     * open and ready to supply input data. Typically this stream
     * corresponds to keyboard input or another input source specified by
     * the host environment or user.
    public final static InputStream in = nullInputStream();and the method
     * The following two methods exist because in, out, and err must be
     * initialized to null.  The compiler, however, cannot be permitted to
     * inline access to them, since they are later set to more sensible values
     * by initializeSystemClass().
    private static InputStream nullInputStream() throws NullPointerException {
     if (currentTimeMillis() > 0)
         return null;
     throw new NullPointerException();
    }if we want to assign the null to the field: in .why we did't do it like this
  public final static InputStream in = null;but use nullInputStream(),instead.

Similar Messages

  • How to load a class dynamically in the current/system class loader

    I need to dynamically load a new jdbc driver jar to the current/system class loader... Please note that creating a new classloader will not help since the DriverManager refers to the systemclassloader itself.
    Restarting the application by appending the jar to its classpath will solve the problem but I want to avoid doing this.

    Did you then create a ClassLoader to load the JDBC
    driver and then install it into the system as
    directed by the JDBC specification (ie
    Class.forName(someClassName))?
    And then try to use it from a class loaded fromsome
    other ClassLoader (i.e. the system class loader)?
    If you did not try this please explain why not.O.K. I just looked at the source to
    java.sql.DriverManager. I did not know what I was
    talking about, as what I suggested above will not
    work.
    This is my new Idea:
    Create a URLClassLoader to load the JDBC driver also
    in this ClassLoader you need to place a helper class
    that does the following:
    public class Helper {
    public Driver getJDBCDriver(String driverClassName,
    String url) {
    try {
    Class.forName(driverClassName);
    Driver d = DriverManager.getDriver(url);
    return d;
    catch(Exception ex) {
    ex.printStackTrace();
    return null;
    }Now create an instance of the Helper class in the new
    ClassLoader, and call its getJDBCDriver method to get
    an instance of the driver (you will probably have to
    create an interface in the root class loader that the
    Helper implements so that you can easily call it).
    Now from the root classloader you can make calls
    directly to the returned Driver and bypass the
    DriverManager and its restrictions on cross
    ClassLoader access.
    The only catch here is that you would have to call to
    the returned Driver directly and not use the Driver
    Manager.This sounds like will work but I did not want to load DriverManager in a new classloader.. I did a hack
    I unzip the jar dynamically in a previously known location (which I included in my classpath when launching the app). The classLoader finds the class now though it did not exist when the app was launched !
    A hack of-course but works eh ..

  • To ragnic and other about Singleton class

    Hi ragnic. Thanks for your reply. I posted the code wrong. Heres' my correct one.
    I have a GUI first loaded information and the information is stored in a databse, I have some EJB classes..and my singleton class ABC has some method to access to the EJB..
    so my first GUI will gather info using singleton class and later if I click on
    a button in my first GUI class, will pop up another frame of another class , this class also need to class setPassword in my Singleton..
    are my followign codes correctly??
    iS my Class ABC a SINgleton class? thanks
    Is my class ABC use as single correctly. And It is called from other classes is also correct?
    I'm new to java and like to learn about Singleton class.
    But I really dont' understand it clearly after reading many examples of it.
    I have a project to convert my class abc to a singleton.
    But I dont know how to do it.
    In my class(soon will become a singleton) will have few methods that later I need to use it from another class A and class B.
    I have a GUI application that first load my class A..and my class will call
    class abc(singleton) to get some information from it.
    and then in class A has a button, if I click on that button I will call SIngleton class again to update my password, in the singleton class has method calls updatePassword. But I dont know how to call a singleton from other class.
    I have my code for them below:
    1)public class ABC //attempt using a singleton
    private static ABC theABC = null;
    private ABC(){}
    public synchronized static ABC getABC()
    if(theABC == null)
    theABC= new ABC();
    return the ABC;
    public void updateUserInfo(SimpleUser user)
    throws UserNotFoundException, DelegateException
    try
    UserCollectionHome userCollectionHome = (UserCollectionHome)
    EJBHomeFactory.getFactory().lookupHome("vista/UserCollection",
    UserCollectionHome.class);
    UserHome userHome = (UserHome)
    EJBHomeFactory.getFactory().lookupHome("vista/User",UserHome.class);
    UserCollection uc = userCollectionHome.create();
    uc.updateUserInfo(user, userHome);
    } catch(HomeFactoryException hfe) {
    hfe.printStackTrace();
    throw new DelegateException(hfe);
    } catch(RemoteException re) {
    re.printStackTrace();
    throw new DelegateException(re);
    } catch(CreateException ce) {
    ce.printStackTrace();
    throw new DelegateException(ce);
    } catch(FinderException fe) {
    fe.printStackTrace();
    throw new UserNotFoundException();
    public SimpleUser getID(String id)
    throws UserNotFoundException, DelegateException
    try
    UserCollectionHome userCollectionHome = (UserCollectionHome)
    EJBHomeFactory.getFactory().lookupHome("vista/UserCollection",
    UserCollectionHome.class);
    UserHome userHome = (UserHome)
    EJBHomeFactory.getFactory().lookupHome("vista/User",UserHome.class);
    UserCollection uc = userCollectionHome.create();
    SimpleUser su = uc.getID(id, userHome);
    return su;
    } catch(HomeFactoryException hfe) {
    throw new DelegateException(hfe);
    } catch(RemoteException re) {
    throw new DelegateException(re);
    } catch(CreateException ce) {
    throw new DelegateException(ce);
    } catch(FinderException fe) {
    throw new UserNotFoundException();
    public void setPassword(String lname,String pw)
    throws UserNotFoundException, DelegateException
    try
    UserCollectionHome userCollectionHome = (UserCollectionHome)
    EJBHomeFactory.getFactory().lookupHome("vista/UserCollection",
    UserCollectionHome.class);
    UserHome userHome = (UserHome)
    EJBHomeFactory.getFactory().lookupHome("vista/User",UserHome.class);
    UserCollection uc = userCollectionHome.create();
    uc.setPassword(lname,pw, userHome);//assume that all lname are differents.
    } catch(HomeFactoryException hfe) {
    hfe.printStackTrace();
    throw new DelegateException(hfe);
    } catch(RemoteException re) {
    re.printStackTrace();
    throw new DelegateException(re);
    } catch(CreateException ce) {
    ce.printStackTrace();
    throw new DelegateException(ce);
    } catch(FinderException fe) {
    fe.printStackTrace();
    throw new UserNotFoundException();
    }//Do I have my class as a Singleton correctly???
    2)//Here is my First Frame that will call a Singleton to gather user information
    public A(Frame owner)
    super(owner, "User Personal Information",true);
    initScreen();
    loadPersonalInfo();
    * This method instantiates all the GUI widgets and places them into panels and
    * onto the frame.
    private void initScreen()
    txtFname = new JTextField(20);
    txtLname=new JTextField(20);
    btnsave =new JButton("Save");
    btnChange= new JButton("Click here to change PW");//when you click this button there will be a frame pop up for you to enter informaton..this iwll call class B
    JPanel pnlMain=new JPanel();
    JPanel pnlFname= new JPanel();
    pnlFname.setLayout(new BoxLayout(pnlFname, BoxLayout.X_AXIS));
    pnlFname.setBorder(BorderFactory.createEmptyBorder(0,87,0,90));
    pnlFname.add(new JLabel("First Name:"));
    pnlFname.add(Box.createRigidArea(new Dimension(5,0)));
    pnlFname.add(txtFname);
    JPanel pnlLname= new JPanel();
    pnlLname.setLayout(new BoxLayout(pnlLname, BoxLayout.X_AXIS));
    pnlLname.setBorder(BorderFactory.createEmptyBorder(0,87,0,90));
    pnlLname.add(new JLabel("Last Name:"));
    pnlLname.add(Box.createRigidArea(new Dimension(5,0)));
    pnlLname.add(txtLname);
    pnlMain.add(pnlFname);
    pnlMain.add(pnlLname);
    pnlMain.add(btnsave);
    pnlMain.add(btnChange");
    btnSave = new JButton("Save");
    btnSave.setActionCommand("SAVE");
    btnSave.addActionListener(this);
    btnCancel = new JButton("Cancel");
    btnCancel.setActionCommand("CANCEL");
    btnCancel.addActionListener(this);
    JPanel pnlBottom = new JPanel();
    pnlBottom.setLayout(new BoxLayout(pnlBottom, BoxLayout.X_AXIS));
    pnlBottom.setBorder(BorderFactory.createEmptyBorder(25,55,0,0));
    pnlBottom.add(btnSave);
    pnlBottom.add(Box.createRigidArea(new Dimension(25,0)));
    pnlBottom.add(btnCancel);
    pnlMain.add(pnlBottom);
    this.setContentPane( pnlMain);
    setSize(500,500);
    GraphicUtilities.center(this);
    theABC=ABC.getABC();
    //Do I call my ABC singleton class correctly??
    private void loadPersonalInfo()
    String ID= System.getProperty("user.name");
    SimpleUser user = null;
    try {
    user = ABC.getID(ID);
    //I tried to use method in ABC singleton class. IS this correctly call?
    } catch(UserNotFoundException nfe)
    JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered.",
    "User Not Found",JOptionPane.WARNING_MESSAGE);
    System.exit(0);
    } catch(DelegateException de) {
    JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered",JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    currentUser = user;
    txtFname.setText(currentUser.getFirstName());
    txtLname.setText(currentUser.getLastName());
    //This information will be display in my textfields Fname and Lname
    //I can change my first and last name and hit button SAVE to save
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand().equals("SAVE")) submitChanges();
    if(e.getActionCommand().equals("CHANGE_PASSWORD")) {
    changepassword=new ChangePassword(new Frame(),name,badgeid);
    public void submitChanges(){
    String currentNTUsername = System.getProperty("user.name");
    SimpleUser user =null;
    try {
    user = theABC.getID(ID);
    user.setFirstName(txtFname.getText().trim());
    user.setLastName(txtLname.getText().trim());
    currentUser = user;
    theABC.updateUserInfo(currentUser);
    //IS this correctly if I want to use this method in singleton class ABC??
    } catch(UserNotFoundException nfe)
    JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered",
    "User Not Found",JOptionPane.WARNING_MESSAGE);
    } catch(DelegateException de) {
    JOptionPane.showMessageDialog(new JDialog(),"You have not yet registered",JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    this.setVisible(false);
    3) click on ChangePassword in my above GUI class A..will call this class B..and in this class B
    I need to access method in a Singleton class- ABC class,,DO i need to inititates it agian, if not what should I do? thanks
    package com.lockheed.vista.userinfo;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    import javax.swing.tree.*;
    import java.util.StringTokenizer;
    import java.util.Vector;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import javax.swing.colorchooser.*;
    import javax.swing.filechooser.*;
    import javax.accessibility.*;
    import java.beans.*;
    import java.applet.*;
    import java.net.*;
    import org.apache.log4j.*;
    import com.lockheed.common.gui.GraphicUtilities;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import vista.user.UserServicesDelegate;
    import vista.user.SimpleUser;
    import vista.user.UserNotFoundException;
    import vista.user.*;
    import com.lockheed.common.ejb.*;
    import com.lockheed.common.gui.*;
    import com.lockheed.vista.publish.*;
    * This program allow users to change their Vista Web Center's password
    public class ChangePassword extends JDialog
    implements ActionListener{
    protected final Logger log = Logger.getLogger(getClass().getName());
    private UserServicesDelegate userServicesDelegate;
    private User currentUser = null;
    private JPasswordField txtPasswd, txtVerifyPW;
    private JButton btnSubmit,btnCancel;
    private JLabel lblName,lblBadgeID;
    private String strBadgeID="";
    * This is the constructor. It creates an instance of the ChangePassword
    * and calls the method to create and build the GUI.
    public ChangePassword(Frame owner,String name,String badgeid)
    super(owner, "Change Password",true);
    initScreen(name,badgeid);//build the GUI
    * This method instantiates all the GUI widgets and places them into panels and
    * onto the frame.
    private void initScreen(String strname,String strBadgeid)
    txtPasswd = new JPasswordField(20);
    txtVerifyPW=new JPasswordField(20);
    txtPasswd.setEchoChar('*');
    txtVerifyPW.setEchoChar('*');
    JPanel pnlMain=new JPanel();
    pnlMain.setLayout(new BoxLayout(pnlMain, BoxLayout.Y_AXIS));
    pnlMain.setBorder(BorderFactory.createEmptyBorder(20,0,20,0));
    JPanel pnlPW=new JPanel();
    pnlPW.setLayout(new BoxLayout(pnlPW, BoxLayout.X_AXIS));
    pnlPW.setBorder(BorderFactory.createEmptyBorder(0,96,0,30));
    pnlPW.add(new JLabel("Password:"));
    pnlPW.add(Box.createRigidArea(new Dimension(5,0)));
    pnlPW.add(txtPasswd);
    JPanel pnlVerifyPW=new JPanel();
    pnlVerifyPW.setLayout(new BoxLayout(pnlVerifyPW, BoxLayout.X_AXIS));
    pnlVerifyPW.setBorder(BorderFactory.createEmptyBorder(0,63,0,30));
    pnlVerifyPW.add(new JLabel("Verify Password:"));
    pnlVerifyPW.add(Box.createRigidArea(new Dimension(5,0)));
    pnlVerifyPW.add(txtVerifyPW);
    JPanel pnlTop= new JPanel();
    pnlTop.add(pnlPW);
    pnlTop.add(Box.createRigidArea(new Dimension(0,10)));
    pnlTop.add(pnlVerifyPW);
    pnlMain.add(pnlTop);
    btnSubmit = new JButton("Submit");
    btnSubmit.setActionCommand("SUBMIT");
    btnSubmit.addActionListener(this);
    btnCancel = new JButton("Cancel");
    btnCancel.setActionCommand("CANCEL");
    btnCancel.addActionListener(this);
    JPanel pnlBottom = new JPanel();
    pnlBottom.setLayout(new BoxLayout(pnlBottom, BoxLayout.X_AXIS));
    pnlBottom.setBorder(BorderFactory.createEmptyBorder(25,55,20,30));
    pnlBottom.add(btnSubmit);
    pnlBottom.add(Box.createRigidArea(new Dimension(25,0)));
    pnlBottom.add(btnCancel);
    pnlMain.add(pnlBottom);
    this.setContentPane( pnlMain);
    setSize(350,230);
    setVisible(true);
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand().equals("CANCEL")) this.setVisible(false);
    if(e.getActionCommand().equals("SUBMIT")) submitPW();
    * This method is called when the submit button is clicked. It allows user to change
    * their password.
    public void submitPW(){
    myABC= ABC.getABC();//Is this correct?
    char[] pw =txtPasswd.getPassword();
    String strPasswd="";
    for(int i=0;i<pw.length;i++){
    strPasswd=strPasswd+pw;
    char[] vpw =txtVerifyPW.getPassword();
    String strVerifyPW="";
    for(int i=0;i<vpw.length;i++){
    strVerifyPW=strVerifyPW+pw;
    if((strPasswd==null)||(strPasswd.length()==0)) {
    JOptionPane.showMessageDialog(new JDialog(),"You have not enter a password. Please try again.",
    "Invalid Password",JOptionPane.ERROR_MESSAGE);
    if((!strPasswd.equals(strVerifyPW)))
    //password and verify password do not match.
    JOptionPane.showMessageDialog(new JDialog(),"Your passwords do not match. Reenter and try again.",
    "Invalid Password",JOptionPane.ERROR_MESSAGE);
    try
    myABC.setUserPassword(strPasswd);//try to use a method in Singleton class
    txtPasswd.setText("");
    txtVerifyPW.setText("");
    this.setVisible(false);
    } catch(DelegateException e) {
    JOptionPane.showMessageDialog(new Frame(),
    "Error.",
    "Unable to change password information.",JOptionPane.WARNING_MESSAGE);
    } catch(UserNotFoundException e) {
    JOptionPane.showMessageDialog(new Frame(),
    "Error.",
    "Unable to change password information.",JOptionPane.WARNING_MESSAGE);
    And ofcourse I have other EJB classes to work with these classes.
    ***It compiles okey but when I ran, it say "NullPointerException"
    I think I call my Singleton wrong.
    Please help me.thanks

    1. When replying, use <reply>, don't post a new topic.
    2. Implementing a singleton is a frequently asked question. Search before you post.
    3. This is not a question about Swing. A more appropriate forum would be "New To Java Technology" or perhaps "Java Programming", but see point 1.
    4. When posting code, keep it short. It increases the chance of readers looking at it. And in composing your shorter version for the forum, you just may solve your problem.

  • Can BEA stop Application code from reaching BEA system class ?

    Hi,
    Does WebLogic Server have any feature through which application code "may not" get access to BEA system classes (like classes in weblogic.jar or any security sensitive classes) ? As I understand, any application user can walk their way to BEA internal classes through classloading heirarchy or reflection ?
    Thanks,
    Krish

    cotton.m wrote:
    baftos wrote:
    Envy wrote:
    Yes perhaps they are behaving differently than my applet and in that case I would be interested to know in what way so that I perhaps can change my applet. My code was included as well so if anyone can see anything that could causethe IE warning it would be nice.
    http://www.lotspiech.com/poker/VideoPokerApplet.html is another example of an applet that doesn't bring upp warnings in Internet explorer.
    Maybe it is because I have a JApplet and not a true Applet.. Or because it is a runnable..
    Edited by: Envy on Feb 12, 2008 12:35 PMHow do you run your applet. I mean what is the page URL? I think if you deploy it on a web server, it should be ok.
    In other words, I think you use now a file URL.
    Seconded!
    Whe run using file URLS (pages you load direct from your disk instead of a webpage) IE whines about all sorts of things it shouldn't. Including JavaScript and for some reason CSS and it would not surprise me in the least that it whined about applets too.
    Try your applet out from an actual URL (one beginning with http) and see what happens. It (IE) will probably shut up.I hope this is OP's problem. I think this is caused by some kind of
    patch to IE security, or, perhaps it's by design. When you go with
    a file URL, the security zone displayed in the status bar is "My computer". In the Tools->Internet Options->Security, there is no place where you can configure this 'zone'. Therefore, they decided to be restrictive about it. In Tools->Internet Options->Advanced, there is a Security section that deals with 'My computer', where you can control this behaviour.

  • Why we can't instantiated System class.

    Hi All,
    I can't undersatnd what type of class is "System". We can't instantiated system class but we can use it like a Static class.

    There are number of classes like that. You don't
    instantiate them because you don't need to.Objects
    have state and behavior. State is captured inmember
    variables. None of the functionality the Systemclass
    provides requires an object to be instantiated and
    maintain state in member variables. It's pure
    behavior.I beg to differ. Given he fact that it has attributes
    (e.g. in, out and err), it does have a state...They're static attributes, so no instance (if one existed) would have its own state that would potentially distinguish it from other instances. That's what I was talking about.
    I, personally, think that static classes are rather
    bad OO (it's objects doing the work, not classes),
    but singletons are too burdensome to create.You mean uninstantiable classes with only static methods? (System is not a static class. Only nested classes can be static.)
    If your goal is to write pure OO, then, yeah, they might be bad. But then I don't think "perfect OO" is a particularly important or useful goal. Tool for the job and all that.

  • System class loader vs application class loader

    Hello
    I have a class that uses a third partyjar which I have put in /jre/lit/ext. The class compiles but fails at runtime being unable to read the property files called in the class' constructor. I believe that is b/c the third party jars are loading w/ the system class loader and cannot "see" the property files "floating" at the same level as the class that is calling them.
    So I created a jar, of the property files, with the same directory/package structure as the location of the property files and put that in the /jre/lib/ext and STILL the same problem; cannot read the property files, the constructor fails, fugly. There is an overloaded constructor that includes a parameter for the property files, but I need to get this to work as is first. What am I missing? Please edify me. tia.

    If the 3rd party jar needs a certain properties file to initialize correctly, I doubt it would be looking for it in the class hierarchy. I mean I doubt it does:
    Properties p = new Properties();
    p.load( getClass().getResourceAsStream() );It's more likely to do:
    Properties p = new Properties();
    p.load( new FileInputStream(...) );The reason is that the property file should be easily edited by the user and users know how to move around in the file system, not in the Java jars and classpaths.
    Just a guess...

  • ERROR: Unable to locate system class: java/lang/String

    I have swtiched from running my application using sun jvm to using microsoft jvm. When i run it i get the following error:
    ERROR: Unable to locate system class: java/lang/String
    java -classpath out;etc..etc myclass
    has become
    jview -cp:a out;C:\build\rt.jar;etc..etc myclass
    any ideas?

    Search for the old "MS SDK for Java 4.0" somewhere (no, you can't find it at Microsoft's site).
    There are two files that you have to get: sdkdocs40.exe (a file with 10,895,496 bytes) and SDKJava40.exe (a file with 20,222,928 bytes).
    Use the embedded jvc compiler to recompile your program. Beware: try not to rely too much in jvc. Use it only for discover that you're using methods not implemented in JDK 1.1.8, but don't use it for deploying your app.
    You'll discover that you'll have to rewrite large portions of your program, and even change your program specifications to deal with the reduced functionality of the old MS JVM (for instance, say that you'll need to change the 'modified date' of a file.
    In JDK >= 1.2 there's the method File.setModified(); in MS JVM you'll need to use some com.ms.wfc function.

  • Need help about Vector class in java

    Hello,
    I have some questions about Vector class. Please see this short code:
    Vector v = new Vector();
    v.add(New Integer(5));
    Is this the only way to add int value into vector? Performance wise, is this slow? And are there any better and faster way to add/get int element fro vector?
    Thank you very much in advance.

    Normally (up to Java version 1.4), that's the only way you can add an int to a Vector. The thing is that Vector can only contain Objects, and an int is a primitive, not an object. So you have to wrap the int in an Integer object.
    However, Java 5 has a new feature, called autoboxing, which means that the compiler automatically wraps primitive values into objects, so that you can program it like this:
    Vector v = new Vector();
    v.add(5);Note, this will not make your program faster or more efficient, because the compiler translates this automatically to:
    Vector v = new Vector();
    v.add(new Integer(5));So in the end, the same bytecode will be produced. Autoboxing is just a feature to make life more convenient for the programmer.

  • QoS System Class change MTU from 9000 to 9126..?

    Hi,
    I want to change the UCS "QoS system Class" MTU for the "Best Effort" class' MTU from 9000 bytes to 9126 as per:
    http://www.cknetworx.net/?tag=ucs-jumbo-frames
         and/or
    http://www.cisco.com/en/US/docs/unified_computing/ucs/UCS_CVDs/esxi51_ucsm2_Clusterdeploy.html
    Making the change is simple enough, however in planning for the change I was hoping to get some sort of idea as to any potential impact the the network.
    - My expectation is that there will be none as I need to upgrade the "QoS system Class" MTU to 9126 to allow me to then upgrade the MTU to specific vNICs (Templates) that I can then schedule and perform in a controlled manner etc.
    Any questions, comments are appreciated.
    Appreciated, Chris.

    Attach the screen shots following.
    OBYC Settings for Service Valuation Class
    Service Master
    PM Order Service Assignment screen with that warning message
    Full Message details of that warning
    Else, discuss with your FICO / MM Consultants.

  • Question about abstract classes and instances

    I have just read about abstract classes and have learned that they cannot be instantiated.
    I am doing some exercises and have done a class named "Person" and an abstract class named "Animal".
    I want to create a method in "Person" that makes it possible to set more animals to Person objects.
    So I wrote this method in class Person and compiled it and did not get any errors, but will this work later when I run the main-method?
    public void addAnimal(Animal newAnimal)
         animal.add(newAnimal);
    }Is newAnimal not an instance?

    Roxxor wrote:
    Ok, but why is it necessary with constructors in abstract classes if we don�t use them (because what I have understand, constructors are used to create objects)?Constructors don't create objects. The new operator creates objects. An object's c'tor is invoked after the object has already been created. The c'tors job is to initialize the newly-created object to a valid state. Whenever a child object is created, the parent's c'tor is run before the child's c'tor, so that by the time we're inside the child's c'tor, setting up the child's state, we know that the parent (or rather the "parent part" of the object we're initializing) is in a valid state.
    Constructor rules:
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a public MyClass() {...} if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor super(...) or a call to another ctor of this class this(...) 2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor super() as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • System Class In Java

    Hi,
    From the Sun Java Docs,I have seen that the System class is a public final class.But it stated in the docs that the class cannot be instantiated. A class cannot be instantiated only when it is an abstract one or it is an interface.Can any one tell me the reason??

    There are other ways to make a class non-instantiable. Making the constructor private is the (first) and only one that comes to mind. Maybe someone else can list other ways.

  • Com.sap.portal.pcm.system.System class???

    Which jar contains com.sap.portal.pcm.system.System class? I am doing a JNDI lookup & context.lookup(SystemID) returns this class com.sap.portal.pcm.system.System.
    I am trying to lookup systems in the system landscape directory.
    I am on SP9.

    Hi Sam,
    You can find it in the com.sap.portal.ivs.systemlandscapeervice_core.jar
    The location of the file is under
    \usr\sap\<SID>\JC00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\portalapps\com.sap.portal.ivs.systemlandscapeervice\private\lib\com.sap.portal.ivs.systemlandscapeervice_core.jar
    Regards
    Prakash

  • ORA-29547: Java system class not available: oracle/aurora/rdbms/Compiler

    Hi experts,
    I get the above error when I run the following code using sqlplus:
    create or replace and compile java source named "DirList"
      2      as
      3      import java.io.*;
      4      import java.sql.*;
      5
      6      public class DirList
      7      {
      8      public static void getList(String directory)
      9                        throws SQLException
    10      {
    11         String element;
    12
    13
    14         File path = new File(directory);
    15         File[] FileList = path.listFiles();
    16         String TheFile;
    17         Date ModiDate;
    18         #sql { DELETE FROM DIR_LIST};
    19
    20         for(int i = 0; i < FileList.length; i++)
    21         {
    22             TheFile = FileList[ i ].getAbsolutePath();
    23             ModiDate = new Date(FileList[ i ].lastModified());
    24
    25             #sql { INSERT INTO DIR_LIST (FILENAME,LASTMODIFIED)
    26                    VALUES (:TheFile,:ModiDate) };
    27         }
    28     }
    29    }
    30  /
    create or replace and compile java source named "DirList"
    ERROR at line 1:
    ORA-29547: Java system class not available: oracle/aurora/rdbms/CompilerAny body can tell me what to do to run external commands like os commands using pl/sql in details with example.
    I will appreciate any sooner response.
    Thanks

    What is the output of this query?
    SQL> select owner, object_name, object_type from dba_objects where object_name = 'oracle/aurora/rdbms/Compiler' ;
    OWNER                          OBJECT_NAME                     OBJECT_TYPE
    SYS                            oracle/aurora/rdbms/Compiler    JAVA CLASS
    PUBLIC                         oracle/aurora/rdbms/Compiler    SYNONYM
    2 rows selected.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    SQL>

  • Why won't -Djava.system.class.loader make it use my ClassLoader?

    I created a class MyAppLoader and installed it in the bootclasspath and used the system property -Djava.system.class.loader. Yet, the JVM won't use my classloader! It's never instantiated (I have a static bit that prints code if it's loaded at all).
    How do I make the JVM use my class as the system classloader?

    send to me some Duke, please Any particular one? I hear the Duke of Northumberland is quite a laugh - would he do?

  • Replacing system class loader

    Hi!
    I'm trying to replace the system class loader for plugin management reasons. I've written a simple test app for testing, but it doesn't work. The first code is a ClassLoader, the second is the main code.
    I try to run the code like this: java -Xbootclasspath/a:. -Djava.system.class.loader=A -cp . B
    It uses my classloader every time, except for when I call Class.forName(). What could be the problem?
    Thanks, Bal�zs
    public class A extends java.lang.ClassLoader {
    public A(ClassLoader parent) {
    super(parent);
    System.out.println("A loaded, parent is " + parent);
    public Class loadClass(String name) throws java.lang.ClassNotFoundException {
    try {
    Class c = getParent().loadClass(name);
    System.out.println("A was asked for " + name + " and delegated it to " + getParent());
    return c;
    } catch (ClassNotFoundException e) {
    System.out.println("A was asked for " + name + " but didn't find it");
    throw new ClassNotFoundException(name + " not found :[");
    }; // ENDOF CLASS A
    public class B {
    public static void main(String[] args) {
    (new B()).proc();
    private void proc() {
    System.out.println("Hello World!");
    System.out.println("Class loader: " + getClass().getClassLoader());
    try {
    Class.forName("C");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    }; // ENDOF CLASS B

    Thanks for the reply. I think I've got a much better idea of how this stuff works now. I think what I need to do is register my deserializer with SOAP as a class that will really load the deserializer using Class.forName() with my class loader as a parameter. Then when the bootstrap class loader can't find a class, findClass() in my classloader will be called and I can load it from a URL.
    Should work.
    Thanks very much!

Maybe you are looking for