Java Class Def Not Found Error

Hi,
When I run a java program(us_noti.sh) I get the following error
======ERROR=========
us_noti.sh
Exception in thread "main" java.lang.NoClassDefFoundError:
org/acplt/oncrpc/XdrAble
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123
at
java.net.URLClassLoader.defineClass(URLClassLoader.java:246)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)======END OF ERROR=========
Any idea what needs to be included in the CLASSPATh for resolving this error. I am running the program on Solaris 2.8
Java Version is as follows
hostname] java -version
java version "1.4.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_03-b04)
Java HotSpot(TM) Client VM (build 1.4.0_03-b04, mixed mode)
Would appreciate any help on this problem..Have been stuck with this for a few days :-((
TIA
Femy

That means u need to have the class or jar files corresponding to
org/acplt/oncrpc/XdrAble
in your jre. giving CLASSPATH helps only for sdk compilation. and with newer versions of jre, even the /bin/jre command is not found. so it is not clear how to install new class or jar files with jre. let sombody who knows enligthen on this
bala

Similar Messages

  • Java class files not found error in jsp sub-directories

    Hello:
    I have a web-application that is setup in the following way:
    index.jsp
    test\index1.jsp
    WEB-INF\classes\test.class
    Both jsp pages index.jsp and index1.jsp uses the test.class in the WEB-INF\classes directory.
    The index.jsp page works fine.
    The test\index1.jsp gives me a "cannot resolve symbol" error. Error shown below:
    [jsp src:line #:19]
    cannot resolve symbol symbol : class test location: class test.index1 test ts = new test("hello");
    Any help at all is appreciated.
    Thanks,
    Benny

    Hello Qiang:
    Thanks a lot for replying, and sorry for the delay in replying back to you. I have been searching the forums for a while and have yet to find anyone else with a similar problem. And yes, it is kinda wierd.
    But, anyways, I checked the java version from the windows command line as follows and it is using version 1.4.2:
    java -version
    java version "1.4.2_04"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
    Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
    Also, here are the contents of my test.class file:
    public class test
    private String t = null;
    public test(String t1)
    setTest(t1);
    public void setTest(String t1)
         t = t1;
    public String getTest()
         return t;
    Here are the contents of my index.jsp file:
    <b> hello </b>
    <%
    String test_str = null;
    test ts = new test("Hello from the main jsp directory");
    test_str = ts.getTest();
    %>
    <b> test_str is: </b> <%=test_str%>
    Click here to test your jsp index1.jsp file in the test sub-directory
    Here are the results from this jsp page:
    hello
    test_str is: Hello from the main jsp directory
    Click here to test your jsp index1.jsp file in the test sub-directory
    Here are the contents from the test/index1.jsp file:
    <b> hello from test sub-directory </b>
    <%
    String test_str = null;
    test ts = new test("Hello from the jsp test sub-directory");
    test_str = ts.getTest();
    %>
    <b> test_str is: </b> <%=test_str%>
    And here is what happens when I try to go to the test/index1.jsp page:
    Request URI:/benny_test/test/index1.jsp
    Exception:
    OracleJSP:oracle.jsp.provider.JspCompileException:
    Errors compiling:C:\OC4J\j2ee\home\application-deployments\default\benny_test\persistence\_pages\_test\_index1.java
    Line #     Error
    47
         [jsp src:line #:5]
    cannot resolve symbol symbol : class test location: class test.index1 test ts = new test("Hello from the jsp test sub-directory");
    47
         [jsp src:line #:5]
    cannot resolve symbol symbol : class test location: class test.index1 test ts = new test("Hello from the jsp test sub-directory");
    I will try putting it in a package like you said and see if that helps. Also, do you see a similar issue in your environment.
    Anyways, thanks for all your help. Hope to hear from you soon.
    Thanks,
    Benny

  • Help with "Java class is not found" error

    Hi,
    I created my java program in a window environment, ran the program to a command line and it works.
    I then put my jar file along with the other dependent jar in unix, I then run the command again and it's complaining that it cannot find the class file from the dependent jar. The class file does exist in the jar and also when I run "java" command I make sure that the jar was part of the classpath.
    My command line looks like this:
    $PS_JRE/bin/java -jar -classpath $CLASSPATH/jxl.jar jexcel.jar
    I'm at a loss. Any advice would be greatly appreciated.
    Thank you,
    Giovanni

    Well, I guess I got it working now.
    The jxl.jar file I was using was compiled with 1.6 The unix server I was compiling on is 1.5.
    Since I can't install a new version of java I was lucky enough to find a version of that api that was compiled with 1.5.
    Now I'm all ok.

  • Error in Installation--The Java class is not found: SDTGui

    I am in the process of instlaling SAP in AIX machine
    When i start the Startsapinst,  i am getting the following error .
    Pls hlep
    <b>The Java class is not found: SDTGui</b>

    I am using humming bird software
    i have set the display.
    Xclock is running
    Pls help

  • SAPinst error:- The java class is not found:  com.sap.engine.offline.Offlin

    Hi,
    I am in the midst of Installing SOLMAN on RHEL5-ORACLE
    Have installed IBM JDK version 1.4.2_10
    During the CREATE SECURE STORE PHASE I am getting the following error:
    sapinst_dev log file O/P
    WARNING[E] 2008-06-09 18:04:43.225
               CJSlibModule::writeError_impl()
    CJS-30050  Cannot create the secure store. SOLUTION: See output of log file SecureStoreCreate.log:
    The java class is not found:  com.sap.engine.offline.OfflineToolStart.
    TRACE      2008-06-09 18:04:43.225 [iaxxejsbas.hpp:483]
               EJS_Base::dispatchFunctionCall()
    JS Callback has thrown unknown exception. Rethrowing.
    TRACE      2008-06-09 18:04:43.243 [syuxctask.cpp:1382]
               CSyTaskImpl::start(bool)
    A child process has been started. Pid = 2529
    TRACE      2008-06-09 18:04:43.281 [syuxctask.cpp:1382]
               CSyTaskImpl::start(bool)
    A child process has been started. Pid = 2530
    ERROR      2008-06-09 18:04:43.310 [sixxcstepexecute.cpp:951]
    FCO-00011  The step createSecureStore with step key |NW_Onehost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|2|0|NW_CreateDBandLoad|ind|ind|ind|ind|10|0|NW_SecureStore|ind|ind|ind|ind|8|0|createSecureStore was executed with status ERROR .
    TRACE      2008-06-09 18:04:43.317 [iaxxgenimp.cpp:752]
                CGuiEngineImp::showMessageBox
    <html> <head> </head> <body> <p> An error occurred while processing service SAP Solution Manager 4.0 Support Release 4 > SAP Systems > Oracle > Central System > Central System. You may now </p> <ul> <li> choose <i>Retry</i> to repeat the current step. </li> <li> choose <i>View Log</i> to get more information about the error. </li> <li> stop the task and continue with it later. </li> </ul> <p> Log files are written to /tmp/sapinst_instdir/SOLMAN/SYSTEM/ORA/CENTRAL/AS. </p> </body></html>
    TRACE      2008-06-09 18:04:43.317 [iaxxgenimp.cpp:1255]
               CGuiEngineImp::acceptAnswerForBlockingRequest
    Waiting for an answer from GUI
    SAPINST.LOG file  O/P
    WARNING 2008-06-09 18:04:43.224
    Execution of the command "/opt/IBMJava2-amd64-142/bin/java -classpath /tmp/sapinst_instdir/SOLMAN/SYSTEM/ORA/CENTRAL/AS/install/sharedlib/launcher.jar -Xmx256m com.sap.engine.offline.OfflineToolStart com.sap.security.core.server.secstorefs.SecStoreFS /tmp/sapinst_instdir/SOLMAN/SYSTEM/ORA/CENTRAL/AS/install/lib:/tmp/sapinst_instdir/SOLMAN/SYSTEM/ORA/CENTRAL/AS/install/sharedlib/exception.jar:/tmp/sapinst_instdir/SOLMAN/SYSTEM/ORA/CENTRAL/AS/install/sharedlib/logging.jar:/tmp/sapinst_instdir/SOLMAN/SYSTEM/ORA/CENTRAL/AS/install/sharedlib/tc_sec_secstorefs.jar create -s SMD -f /sapmnt/SMD/global/security/data/SecStore.properties -k /sapmnt/SMD/global/security/data/SecStore.key -enc -p XXXXXX" finished with return code 1. Output:
    The java class is not found:  com.sap.engine.offline.OfflineToolStart
    WARNING[E] 2008-06-09 18:04:43.225
    CJS-30050  Cannot create the secure store. SOLUTION: See output of log file SecureStoreCreate.log:
    The java class is not found:  com.sap.engine.offline.OfflineToolStart.
    ERROR 2008-06-09 18:04:43.310
    FCO-00011  The step createSecureStore with step key |NW_Onehost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|2|0|NW_CreateDBandLoad|ind|ind|ind|ind|10|0|NW_SecureStore|ind|ind|ind|ind|8|0|createSecureStore was executed with status ERROR .
    SecurStoreCreate log O/P
    The java class is not found:  com.sap.engine.offline.OfflineToolStart
    Pls suggest how to resolve this issue
    Pls help to resolve this issue
    Rgds,
    Abhijeet

    Hi All,
    I Found the Solution.
    The SAPinst tool was somehow not able to extracte the
    J2EEINSTALL.SAR files from the JAVA Components DVD.
    So I manually extracted the the file in the temporary install folder which the SAPinst creates in the /tmp filesystem (on LINUX by deafult) during the installation process.
    The following command is used (I used this on Red Hat LINUX 5.2) to extract the J2EEINSTALL.SAR file:-
    /sapmnt/SMD/exe/SAPCAR
    -xvf /dump/SR4_Java_Components/D51033521/DATA_UNITS/JAVA_J2EE_OSINDEP_J2EE_INST/J2EEINSTALL.SAR
    /sapmnt/SMD/exe/SAPCAR -->source directory of the file SAPCAR which is used to extarct CAR / SAR files on UNIX
    /dump/SR4_Java_Components/D51033521/DATA_UNITS/JAVA_J2EE_OSINDEP_J2EE_INST/J2EEINSTALL.SAR--> destination dir. where the SAPinst tool will read and execute the file.
    Rgds,
    Abhijeet K

  • The java class is not found:  com.sap.inst.migmon.exp. "During export "

    Hello all,
    I am trying to run export of PI system (ABAP+JAVA) uisng inst master NWSR3
    I am hit with an issue before the export_ABAP starts . the following are the error lines
    java version "1.4.2"
    Java(TM) 2 Runtime Environment, Standard Edition (build 2.3)
    IBM J9 VM (build 2.3, J2RE 1.4.2 IBM J9 2.3 AIX ppc64-64 j9ap64142-20070708 (JIT enabled)
    J9VM - 20070530_12820_BHdSMr
    JIT  - 20070529_1824_r8
    GC   - 20070328_AA)
    The java class is not found:  com.sap.inst.migmon.exp.ExportMonitor
    Please share if there are any possible solutions to overcome this error & make export run smoother
    thanks & regards,
    rahul

    Hello,
    Please check the JVM-settings as per note
    1024539 (including the environment-variables and APARS).
    For some reason the 'migmon.jar' - file can no longer
    be found in your installation directory
    It might be sufficient to copy the archive 'MIGMON.SAR' from your
    master-cd (subdirectory IM_AIX_PPC64/COMMON/INSTALL) to your
    installation directory and extract the archive there by 'SAPCAR -xvf
    If the problem persists
    apply the latest patch as per note
    784118 System Copy Java Tools
    regards,
    John Feely

  • "The java class is not found:" post clone

    Hi.
    I've just cloned an 11.5.10.2 environment from one AIX5.2 server running 9.2.0.7 to another server at the same AIX and RDBMS level.
    After running the clone steps, the application was automatically started and I was able to access it via Self Service, forms, run concurrent requests etc - in short, I had a working system.
    Now, however, when I try to stop or start the application using adstrtal.sh/adstpall.sh, I hit the following:
    "The java class is not found: oracle/apps/ad/autoconfig/ServiceControl
    Check logfile /data/testcomn/admin/log/TEST_ireaix2/05011011.log for details"
    On the command line, when I call the line the script is trying to execute:
    /usr/java14/bin/java -classpath "${CLASSPATH}:${JAVA_TOP}:${FND_TOP}/java/3rdparty/stdalone/xmlparserv2.zip" oracle.apps.ad.autoconfig.ServiceControl -e /oracle/testappl/admin/TEST_ireaix2.xml -u apps/<PASS> -m 2 -l yadda –debug
    I'm able to bypass this particular error and some of the application processes do start but not all of them and obviously I still have an underlying Java/environment issue.
    Any suggestions gratefully received.
    Rgds,
    Jes

    Check logfile /data/testcomn/admin/log/TEST_ireaix2/05011011.log for details"What does the log file say?

  • "The java class is not found:"  during cloning

    Hi.
    I've just cloned an 11.5.10.2 environment from one AIX5.2 server running 9.2.0.7 to another server at the same AIX and RDBMS level.
    After running the clone steps, the application was automatically started and I was able to access it via Self Service, forms, run concurrent requests etc - in short, I had a working system.
    Now, however, when I try to stop or start the application using adstrtal.sh/adstpall.sh, I hit the following:
    "The java class is not found: oracle/apps/ad/autoconfig/ServiceControl
    Check logfile /data/testcomn/admin/log/TEST_ireaix2/05011011.log for details"
    On the command line, when I call the line the script is trying to execute:
    /usr/java14/bin/java -classpath "${CLASSPATH}:${JAVA_TOP}:${FND_TOP}/java/3rdparty/stdalone/xmlparserv2.zip" oracle.apps.ad.autoconfig.ServiceControl -e /oracle/testappl/admin/TEST_ireaix2.xml -u apps/starl1ght -m 2 -l yadda –debug
    I'm able to bypass this particular error and some of the application processes do start but not all of them and obviously I still have an underlying Java/environment issue.
    Any suggestions gratefully received.
    Rgds,
    Jes

    May be you should try posting this on an appropriate forum to get a speedier response.
    Regards

  • The java class is not found:  oracle/aurora/util/Wrapper

    When I try and load my Java class file using 'loadjava' into Oracle I'm getting the error:
    The java class is not found: oracle/aurora/util/Wrapper
    What is causing this?

    On which machine should ORACLE_SID be set to solve this problem, server or client. I run into this error when run loadjava

  • The java class is not found:  oracle.apex.APEXExport

    Hi,
    when i run java oracle.apex.APEXExport
    i have the error
    The java class is not found: oracle.apex.APEXExport
    CLASSPATH=/opt/ora/admin/Apex_Backup/class/classes12.zip:/opt/ora/admin/Apex_Backup/APEXExport.class
    also
    CLASSPATH=/opt/ora/admin/Apex_Backup/class/classes12.zip
    causes the error
    Can somebody help he out of this?

    Hello,
    Take a look at my blog post on Backing Up Your Applications, available here -
    http://jes.blogs.shellprompt.net/2006/12/12/backing-up-your-applications/
    I run through all the steps you need to do to get it working.
    Hope this helps,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Overview of Leave --- CREATE OBJECT: The class  was not found., error key:

    Dear Gurus,
    Iam facing this problem that, when i try to open the Leave Overview from the leave request screen. it gives the dump with message
    CREATE OBJECT: The class  was not found., error key: RFC_ERROR_SYSTEM_FAILURE   
    this also creates a dump in the back end.
    The same dump is appearing when i try to view the Check Documents for the same employee from PTARQ.
    Thanks in advance
    Ramnath

    Hi ,
    please find the following solution .it will definitely work .
    If you leave configuration is done.
    There was an incorrect data in your system. To do these please follow following process.
    delete this request using
    PTARQ> Delete documents (RPTARQDBDEl)
    Please read the report documentation before
    deleting the request but it should be safe as it is
    a development system.
    Please delete this with the above information or delete all
    the records for the approver.
    After this,, there will be some incorrect workitem in approver inbox.
    You need to clear that also by Tcode - SWWL.
    ALSO check the leave request workflow of that employee and if there is any error workflow lying in the workflow delete the leave request (which was created with error) Note down the id initiater ( which had error) and in the Test Environment for Leave request (PTARQ) gave the PERNR and delete the documents ( give the id iniater in the document status ).
    To check the error work flow go to SWIA and check for that Workflow (Leave) raised by the PERNR at that duration ( check in IT2001 for the duration) and give it here.
    After deleting it check in the portal for the leave request if any error is occuring when trying to apply for leave.

  • SOAP  oracle xml sql utility class definition not found error

    I have created a java class that connects to database using JDBC runs an sql statement and produces xml using Oracle XML SQL Utility class. The java class works perfectly when I deploy it as a soap web service and try to run through SOAP server it gives a SOAP error oracle/xml/sql/query/OracleXML/Query [java.lang.NoClassDefFoundError].
    Can anyone help please.
    Thanks
    Alina

    Sounds like you have not included the xsu12.jar file in the server-side CLASSPATH.
    This depends also on the xmlparserv2.jar and on the Oracle JDBC driver. Later versions
    of XSU may also depend on the xdb.jar file, too.

  • Error:Class java.util.date not found

    i have installed 9iAS on my computer.And i want to develop program on JSP.i tried the url below
    http://eyuksel/servlet/IsItWorking
    and i got "it is working" message.when i try to execute my first jsp file i get the error:
    Errors compiling:d:\ias\apache\apache\htdocs\_pages\\_first.java
    d:\ias\apache\apache\htdocs\_pages\_first.java:55: Class java.util.date not found.
    out.print( new java.util.date() );
    ^
    1 error
    what must i do or how can i install the java classes.
    kind regards...
    null

    Thank you very much.It worked:)
    Java is case-sensitive.
    try
    java.util.Date
    instead of
    java.util.date
    null

  • Error(23,19): method getName(java.lang.String) not found in class javax.swi

    Hi , when i try to run my program, i keep getting the error msg:
    Error(23,19): method getName(java.lang.String) not found in class javax.swing.JTextField
    I have checked the java API and it inherits from the awt.Component class and should be accessible via the jtextfield.
    I have tried the following:
    trying to initailise the JTextField at the start.
    Using getName works if i use it within the loop after setting the name.
    Does anybody know what i am doing wrong please?
    public class clsMember extends JPanel implements ActionListener {
        private JButton jbtnLog;
        private String surname;
        private JTextField txtItem;
        public clsMember() {
            super(new SpringLayout());
            makeInterface();
            surname = txtItem.getName("Surname").toString();
    private void makeInterface() {
         //code omitted
               for (int i = 0; i < numpairs; i++) {
                JLabel l = new JLabel(strLabels, JLabel.LEADING);
    this.add(l);
    //if the array item is salutation create a combobox
    if (strLabels[i] == "Salutation") {
    jcomSalutation = new JComboBox(strSalutation);
    jcomSalutation.setSelectedIndex(0);
    this.add(jcomSalutation);
    } else {
    txtItem = new JTextField(10);
    l.setLabelFor(txtItem);
    txtItem.setName(strLabels[i].replaceAll(" ", "")); //this is where the label is set and if i do a system.out it shows fine. getName works here too.
    this.add(txtItem);
    //code omitted

    If i have a loop that creates the jtextfields such as
                    txtItem = new JTextField(10);
                    l.setLabelFor(txtItem);
                    txtItem.setName(strLabels.replaceAll(" ", ""));
    this.add(txtItem);How is it then possible to assign to a string the value of a *specific jtextfield*. Lets say that one of these JTextfields has the name surname.
    How is it possible for me to writeString surname = surnamejtextfield.getText();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • "Class Circle not found in TryBouncingBalls" error message. Help !

    Dear People,
    I have an error message :
    "TryBouncingBalls.java": Error : class Circle not found in class stan_bluej_ch5_p135.TryBouncingBalls at line 67, "
    Circle circle = new Circle(xPos + 130, 30);
    below are the classes TryBouncingBalls, BouncingBall, BallDemo, Canvas
    Thank you in advance
    Stan
    package stan_bluej_ch5_p135;
    import java.awt.*;
    import java.awt.geom.*;
    public class TryBouncingBalls
    public static void main(String[] args)
    Canvas myCanvas = new Canvas("Creativity at its best");
    myCanvas.setVisible(true);
    BouncingBall ball = new BouncingBall(50,50,16, Color.red, 500, myCanvas);
    BouncingBall ball2 = new BouncingBall(70,80,20, Color.green, 500, myCanvas);
    BouncingBall ball3 = new BouncingBall(90,100,16, Color.red, 500, myCanvas);
    BouncingBall ball4 = new BouncingBall(30,30,20, Color.green, 500, myCanvas);
    ball.draw();
    ball2.draw();
    ball.draw();
    ball2.draw();
    // make them bounce
    boolean finished = false;
    while(!finished) {
    myCanvas.wait(50); // small delay
    ball.move();
    ball2.move();
    ball3.move();
    ball4.move();
    // stop once ball has travelled a certain distance on x axis
    if(ball.getXPosition() >= 550 && ball2.getXPosition() >= 550)
    finished = true;
    myCanvas.setFont(new Font("helvetica", Font.BOLD, 14));
    myCanvas.setForegroundColor(Color.red);
    myCanvas.drawString("We are having fun, ...\n\n", 20, 30);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.black);
    myCanvas.drawString("...drawing lines...", 60, 60);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawLine(200, 20, 300, 50);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.blue);
    myCanvas.drawLine(220, 100, 370, 40);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.green);
    myCanvas.drawLine(290, 10, 320, 120);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawString("...and shapes!", 110, 90);
    myCanvas.setForegroundColor(Color.red);
    myCanvas.drawString("to bring to focus creative ideas !", 310, 290);
    // the shape to draw and move
    int xPos = 10;
    Rectangle rect = new Rectangle(xPos + 40, 150, 30, 20);
    Rectangle rect2 = new Rectangle(xPos + 80, 120, 50, 25);
    Rectangle rect3 = new Rectangle(xPos+ 1200, 180, 30, 30);
    Rectangle rect4 = new Rectangle(xPos + 150, 220, 40, 15);
    myCanvas.fill(rect);
    myCanvas.fill(rect2);
    myCanvas.fill(rect3);
    myCanvas.fill(rect4);
    Circle circle = new Circle(xPos + 130, 30);
    // Circle circle2 = new Circle(xPos + 150, 50);
    // Circle circle3 = new Circle(xPos + 170, 30);
    // Circle circle4 = new Circle(xPos + 200, 40);
    // myCanvas.fill(circle);
    // myCanvas.fill(circle2);
    // myCanvas.fill(circle3);
    // myCanvas.fill(circle4);
    // move the rectangle and circles across the screen
    for(int i = 0; i < 200; i ++) {
    myCanvas.fill(rect);
    myCanvas.fill(rect2);
    myCanvas.fill(rect3);
    myCanvas.fill(rect4);
    myCanvas.wait(10);
    myCanvas.erase(rect);
    myCanvas.erase(rect2);
    myCanvas.erase(rect3);
    myCanvas.erase(rect4);
    xPos++;
    rect.setLocation(xPos, 150);
    rect2.setLocation(xPos, 120);
    rect3.setLocation(xPos, 180);
    rect4.setLocation(xPos, 220);
    // at the end of the move, draw once more so that it remains visible
    myCanvas.fill(rect);
    myCanvas.fill(rect2);
    myCanvas.fill(rect3);
    myCanvas.fill(rect4);
    package stan_bluej_ch5_p135;
    import java.awt.*;
    import java.awt.geom.*;
    * Class BouncingBall - a graphical ball that observes the effect of gravity. The ball
    * has the ability to move. Details of movement are determined by the ball itself. It
    * will fall downwards, accelerating with time due to the effect of gravity, and bounce
    * upward again when hitting the ground.
    * This movement can be initiated by repeated calls to the "move" method.
    * @author Bruce Quig
    * @author Michael Kolling (mik)
    * @author David J. Barnes
    * @version 1.1 (23-Jan-2002)
    public class BouncingBall
    private static final int gravity = 3; // effect of gravity
    private int ballDegradation = 2;
    private Ellipse2D.Double circle;
    private Color color;
    private int diameter;
    private int xPosition;
    private int yPosition;
    private final int groundPosition; // y position of ground
    private Canvas canvas;
    private int ySpeed = 1; // initial downward speed
    * Constructor for objects of class BouncingBall
    * @param xPos the horizontal coordinate of the ball
    * @param yPos the vertical coordinate of the ball
    * @param ballDiameter the diameter (in pixels) of the ball
    * @param ballColor the color of the ball
    * @param groundPos the position of the ground (where the wall will bounce)
    * @param drawingCanvas the canvas to draw this ball on
    public BouncingBall(int xPos, int yPos, int ballDiameter, Color ballColor,
    int groundPos, Canvas drawingCanvas)
    xPosition = xPos;
    yPosition = yPos;
    color = ballColor;
    diameter = ballDiameter;
    groundPosition = groundPos;
    canvas = drawingCanvas;
    * Draw this ball at its current position onto the canvas.
    public void draw()
    canvas.setForegroundColor(color);
    canvas.fillCircle(xPosition, yPosition, diameter);
    * Erase this ball at its current position.
    public void erase()
    canvas.eraseCircle(xPosition, yPosition, diameter);
    * Move this ball according to its position and speed and redraw.
    public void move()
    // remove from canvas at the current position
    erase();
    // compute new position
    ySpeed += gravity;
    yPosition += ySpeed;
    xPosition +=2;
    // check if it has hit the ground
    if(yPosition >= (groundPosition - diameter) && ySpeed > 0) {
    yPosition = (int)(groundPosition - diameter);
    ySpeed = -ySpeed + ballDegradation;
    // draw again at new position
    draw();
    * return the horizontal position of this ball
    public int getXPosition()
    return xPosition;
    * return the vertical position of this ball
    public int getYPosition()
    return yPosition;
    package stan_bluej_ch5_p135;
    import java.awt.*;
    import java.awt.geom.*;
    * Class BallDemo - provides two short demonstrations showing how to use the
    * Canvas class.
    * @author Michael Kolling and David J. Barnes
    * @version 1.0 (23-Jan-2002)
    public class BallDemo
    private Canvas myCanvas;
    * Create a BallDemo object. Creates a fresh canvas and makes it visible.
    public BallDemo()
    myCanvas = new Canvas("Ball Demo", 600, 500);
    myCanvas.setVisible(true);
    * This method demonstrates some of the drawing operations that are
    * available on a Canvas object.
    public void drawDemo()
    myCanvas.setFont(new Font("helvetica", Font.BOLD, 14));
    myCanvas.setForegroundColor(Color.red);
    myCanvas.drawString("We can draw text, ...", 20, 30);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.black);
    myCanvas.drawString("...draw lines...", 60, 60);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawLine(200, 20, 300, 50);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.blue);
    myCanvas.drawLine(220, 100, 370, 40);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.green);
    myCanvas.drawLine(290, 10, 320, 120);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawString("...and shapes!", 110, 90);
    myCanvas.setForegroundColor(Color.red);
    // the shape to draw and move
    int xPos = 10;
    Rectangle rect = new Rectangle(xPos, 150, 30, 20);
    // move the rectangle across the screen
    for(int i = 0; i < 200; i ++) {
    myCanvas.fill(rect);
    myCanvas.wait(10);
    myCanvas.erase(rect);
    xPos++;
    rect.setLocation(xPos, 150);
    // at the end of the move, draw once more so that it remains visible
    myCanvas.fill(rect);
    * Simulates two bouncing balls
    public void bounce()
    int ground = 400; // position of the ground line
    myCanvas.setVisible(true);
    // draw the ground
    myCanvas.drawLine(50, ground, 550, ground);
    // crate and show the balls
    BouncingBall ball = new BouncingBall(50, 50, 16, Color.blue, ground, myCanvas);
    ball.draw();
    BouncingBall ball2 = new BouncingBall(70, 80, 20, Color.red, ground, myCanvas);
    ball2.draw();
    // make them bounce
    boolean finished = false;
    while(!finished) {
    myCanvas.wait(50); // small delay
    ball.move();
    ball2.move();
    // stop once ball has travelled a certain distance on x axis
    if(ball.getXPosition() >= 550 && ball2.getXPosition() >= 550)
    finished = true;
    ball.erase();
    ball2.erase();
    package stan_bluej_ch5_p135;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    * Class Canvas - a class to allow for simple graphical
    * drawing on a canvas.
    * @author Michael Kolling (mik)
    * @author Bruce Quig
    * @version 1.8 (23.01.2002)
    public class Canvas
    private JFrame frame;
    private CanvasPane canvas;
    private Graphics2D graphic;
    private Color backgroundColor;
    private Image canvasImage;
    * Create a Canvas with default height, width and background color
    * (300, 300, white).
    * @param title title to appear in Canvas Frame
    public Canvas(String title)
    this(title, 600, 600, Color.white);
    * Create a Canvas with default background color (white).
    * @param title title to appear in Canvas Frame
    * @param width the desired width for the canvas
    * @param height the desired height for the canvas
    public Canvas(String title, int width, int height)
    this(title, width, height, Color.white);
    * Create a Canvas.
    * @param title title to appear in Canvas Frame
    * @param width the desired width for the canvas
    * @param height the desired height for the canvas
    * @param bgClour the desired background color of the canvas
    public Canvas(String title, int width, int height, Color bgColor)
    frame = new JFrame();
    canvas = new CanvasPane();
    frame.setContentPane(canvas);
    frame.setTitle(title);
    canvas.setPreferredSize(new Dimension(width, height));
    backgroundColor = bgColor;
    frame.pack();
    * Set the canvas visibility and brings canvas to the front of screen
    * when made visible. This method can also be used to bring an already
    * visible canvas to the front of other windows.
    * @param visible boolean value representing the desired visibility of
    * the canvas (true or false)
    public void setVisible(boolean visible)
    if(graphic == null) {
    // first time: instantiate the offscreen image and fill it with
    // the background color
    Dimension size = canvas.getSize();
    canvasImage = canvas.createImage(size.width, size.height);
    graphic = (Graphics2D)canvasImage.getGraphics();
    graphic.setColor(backgroundColor);
    graphic.fillRect(0, 0, size.width, size.height);
    graphic.setColor(Color.black);
    frame.show();
    * Provide information on visibility of the Canvas.
    * @return true if canvas is visible, false otherwise
    public boolean isVisible()
    return frame.isVisible();
    * Draw the outline of a given shape onto the canvas.
    * @param shape the shape object to be drawn on the canvas
    public void draw(Shape shape)
    graphic.draw(shape);
    canvas.repaint();
    * Fill the internal dimensions of a given shape with the current
    * foreground color of the canvas.
    * @param shape the shape object to be filled
    public void fill(Shape shape)
    graphic.fill(shape);
    canvas.repaint();
    * Fill the internal dimensions of the given circle with the current
    * foreground color of the canvas.
    public void fillCircle(int xPos, int yPos, int diameter)
    Ellipse2D.Double circle = new Ellipse2D.Double(xPos, yPos, diameter, diameter);
    fill(circle);
    * Fill the internal dimensions of the given rectangle with the current
    * foreground color of the canvas. This is a convenience method. A similar
    * effect can be achieved with the "fill" method.
    public void fillRectangle(int xPos, int yPos, int width, int height)
    fill(new Rectangle(xPos, yPos, width, height));
    * Erase the whole canvas.
    public void erase()
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    Dimension size = canvas.getSize();
    graphic.fill(new Rectangle(0, 0, size.width, size.height));
    graphic.setColor(original);
    canvas.repaint();
    * Erase the internal dimensions of the given circle. This is a
    * convenience method. A similar effect can be achieved with
    * the "erase" method.
    public void eraseCircle(int xPos, int yPos, int diameter)
    Ellipse2D.Double circle = new Ellipse2D.Double(xPos, yPos, diameter, diameter);
    erase(circle);
    * Erase the internal dimensions of the given rectangle. This is a
    * convenience method. A similar effect can be achieved with
    * the "erase" method.
    public void eraseRectangle(int xPos, int yPos, int width, int height)
    erase(new Rectangle(xPos, yPos, width, height));
    * Erase a given shape's interior on the screen.
    * @param shape the shape object to be erased
    public void erase(Shape shape)
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    graphic.fill(shape); // erase by filling background color
    graphic.setColor(original);
    canvas.repaint();
    * Erases a given shape's outline on the screen.
    * @param shape the shape object to be erased
    public void eraseOutline(Shape shape)
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    graphic.draw(shape); // erase by drawing background color
    graphic.setColor(original);
    canvas.repaint();
    * Draws an image onto the canvas.
    * @param image the Image object to be displayed
    * @param x x co-ordinate for Image placement
    * @param y y co-ordinate for Image placement
    * @return returns boolean value representing whether the image was
    * completely loaded
    public boolean drawImage(Image image, int x, int y)
    boolean result = graphic.drawImage(image, x, y, null);
    canvas.repaint();
    return result;
    * Draws a String on the Canvas.
    * @param text the String to be displayed
    * @param x x co-ordinate for text placement
    * @param y y co-ordinate for text placement
    public void drawString(String text, int x, int y)
    graphic.drawString(text, x, y);
    canvas.repaint();
    * Erases a String on the Canvas.
    * @param text the String to be displayed
    * @param x x co-ordinate for text placement
    * @param y y co-ordinate for text placement
    public void eraseString(String text, int x, int y)
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    graphic.drawString(text, x, y);
    graphic.setColor(original);
    canvas.repaint();
    * Draws a line on the Canvas.
    * @param x1 x co-ordinate of start of line
    * @param y1 y co-ordinate of start of line
    * @param x2 x co-ordinate of end of line
    * @param y2 y co-ordinate of end of line
    public void drawLine(int x1, int y1, int x2, int y2)
    graphic.drawLine(x1, y1, x2, y2);
    canvas.repaint();
    * Sets the foreground color of the Canvas.
    * @param newColor the new color for the foreground of the Canvas
    public void setForegroundColor(Color blue)
    graphic.setColor(Color.blue);
    * Returns the current color of the foreground.
    * @return the color of the foreground of the Canvas
    public Color getForegroundColor()
    return graphic.getColor();
    * Sets the background color of the Canvas.
    * @param newColor the new color for the background of the Canvas
    public void setBackgroundColor(Color newColor)
    backgroundColor = newColor;
    graphic.setBackground(newColor);
    * Returns the current color of the background
    * @return the color of the background of the Canvas
    public Color getBackgroundColor()
    return backgroundColor;
    * changes the current Font used on the Canvas
    * @param newFont new font to be used for String output
    public void setFont(Font newFont)
    graphic.setFont(newFont);
    * Returns the current font of the canvas.
    * @return the font currently in use
    public Font getFont()
    return graphic.getFont();
    * Sets the size of the canvas.
    * @param width new width
    * @param height new height
    public void setSize(int width, int height)
    canvas.setPreferredSize(new Dimension(width, height));
    Image oldImage = canvasImage;
    canvasImage = canvas.createImage(width, height);
    graphic = (Graphics2D)canvasImage.getGraphics();
    graphic.drawImage(oldImage, 0, 0, null);
    frame.pack();
    * Returns the size of the canvas.
    * @return The current dimension of the canvas
    public Dimension getSize()
    return canvas.getSize();
    * Waits for a specified number of milliseconds before finishing.
    * This provides an easy way to specify a small delay which can be
    * used when producing animations.
    * @param milliseconds the number
    public void wait(int milliseconds)
    try
    Thread.sleep(milliseconds);
    catch (InterruptedException e)
    // ignoring exception at the moment
    * Nested class CanvasPane - the actual canvas component contained in the
    * Canvas frame. This is essentially a JPanel with added capability to
    * refresh the image drawn on it.
    private class CanvasPane extends JPanel
    public void paint(Graphics g)
    g.drawImage(canvasImage, 0, 0, null);

    Dear Miciuli,
    I found the definition for the circle in the canvas class and used it to creates circles ! Thank you for jaring my brain into thinking !
    Stan
    Ellipse2D.Double circle = new Ellipse2D.Double(xPos, 70, 30 , 30);

Maybe you are looking for

  • Passing JavaScript value to Jsp

    Hi, Any idea how to pass a value from javascript to jsp page when the page gets load on browser. I use below code but an event is require to pass the value. Is there any code that pass automatically the value from javascript to jsp. <html> <head> <ti

  • LaserJet Pro P1102w and Chromebook

    I cannot connect my new Google Chromebook to my new hp LaserJet Pro P1102w printer.  The Chromebook requires an address that ends in @HPprint.com.   I have been trying to find out how to register for that email for at least an hour. Can anyone tell m

  • How do I get my favorites (huge) to come over the Firefox from MS? I find firefox much faster on teh web also for some reason.

    How can I transfer my long list of organized favorites I have on MS Internet Explorer over to Firefox?

  • Develop module in LR 4.4

    I have just updated from Lightroom 3 to Lightroom 4.4. In using Darren Rowse's tutorial he mentions using the Recovery Slider and the Fill in Tool. These 2 sliders do not appear in the develop module in 4.4 They were visable in Lightroom 3 but are no

  • Re: search help for distribution field name

    hi to all, i had written like this select-options: s_manif for sood-objnam no intervals.i want a search help for this so that i want to select a distibution list names. how i can go head. please help me in this regard thanks sun Message was edited by