Java Programming, 100 locker problem

hello i am intro to programming in java.. i have a problem from my teacher. 100 lockers are all open in an array. 1 person goes in changes all to closed. 2 every other. 3 every third, 4 every fourth and so on until 100. could some1 give me a walktrhough for some help. i understand i have to create the array. and i understand 0= open 1= closed. n= 1 (student).. n++ but other than that i am kind of stuck!.. any help and i would appreciate it.
thanks!

thats that helps alot.. could you help me decode some of this code i found into english so i can write my own version so it is not plagurism.
public static void main(String[] args) {
boolean [] lockers = new boolean [101];
     for(int i = 1; i < lockers.length; i++)
          lockers[i] = true;
for(int i = 2; i < lockers.length; i += 2)
     lockers[i] = false;
for(int i = 3; i < lockers.length; i++) {                      
     for(int j = 1; j < lockers.length; j++) {                               
          if(j % i == 0)
               lockers[j] =! lockers[j]; }}
System.out.print("Open lockers: ");
     for(int i = 1; i < lockers.length; i++) {                       
     if(lockers)
          System.out.print(" " + i);
               System.out.println();

Similar Messages

  • The JAVA program for "Philosopher Problem"

    When I learn the book of "Operating Systems (Design and Implementation)"(written by Andrew S.Tanenbaum), I try to write a program for the "Philosopher Problem" . In the book there is a sample of this problem in C language, and I write it in JAVA. The following is my program, I have tested it. It is correct, but maybe it is not the most efficient way to solve the problem. Can you think out a more efficient program in JAVA to solve this problem?
    * Philosopher Eating Problem
    * @author mubin
    * @version 1.0
    public class PhilosopherEating {
    //Philosophers' number
    private final static int PHER_NUM = 20;
    //Philosophers' state
    private volatile static int[] pherState = new int[PHER_NUM];
    //THINKING
    private final static int THINKING = 0;
    //HUNGRY
    private final static int HUNGRY = 1;
    //EATING
    private final static int EATING = 2;
    //Philosophers thread group
    public static Philosopher[] philosophers = new Philosopher[PHER_NUM];
    //finish indicator
    public volatile static boolean finished =false;
    //thread lock
    public static Object threadLock = new Object();
    public PhilosopherEating() {
    * Philosopher class
    * @author mubin
    * @version 1.0
    public static class Philosopher extends Thread{
    int pherNo ;
    public Philosopher(int no){
    this.pherNo = no;
    public void run(){
    while(!PhilosopherEating.finished){
    think();
    takeForks(this.pherNo);
    eat();
    putForks(this.pherNo);
    * Thinking
    private void think(){
    System.out.println("Philosopher"+this.pherNo+"is thinking...");
    try {
    Thread.sleep( (int)(Math.random()*100));
    }catch (Exception ex) {
    ex.printStackTrace(System.out);
    * Eating
    private void eat(){
    System.out.println("Philosopher"+this.pherNo+"is eating...");
    try {
    Thread.sleep( (int)(Math.random()*100));
    }catch (Exception ex) {
    ex.printStackTrace(System.out);
    * Take the fork
    private void takeForks(int no){
    //System.out.println("takeForks:no:"+no);
    synchronized (threadLock) {
    pherState[no] = HUNGRY;
    testPher(no);
    * Put down the fork
    private void putForks(int no){
    //System.out.println("putForks:no:"+no);
    synchronized (threadLock) {
    pherState[no] = THINKING;
    if( pherState[getLeft()]==HUNGRY ){
    philosophers[getLeft()].interrupt();
    if( pherState[getRight()]==HUNGRY ){
    philosophers[getRight()].interrupt();
    * Return the NO. of philosopher who is sitting at the left side of this philosopher
    * @return the NO. of the left philosopher
    private int getLeft(){
    int ret = (pherNo-1)<0? PHER_NUM-1 : (pherNo-1);
    return ret;
    * Return the NO. of philosopher who is sitting at the right side of this philosopher
    * @return the NO. of the right philosopher
    private int getRight(){
    int ret = (pherNo+1)>=PHER_NUM ? 0 :(pherNo+1);
    return ret;
    private void testPher(int no){
    while(true){
    if(pherState[no]==HUNGRY
    &&pherState[getLeft()]!=EATING
    &&pherState[getRight()]!=EATING) {
    pherState[no] = EATING;
    //Print and check the philosophers' state
    printPher(pherState);
    return;
    }else{
    try {
    System.out.println(" Philosopher "+this.pherNo+"is waiting a fork");
    threadLock.wait();
    }catch (java.lang.InterruptedException ex) {
    System.out.println(" Philosopher "+this.pherNo+"is interrupted and woken up to take fork");
    //when it is interrupted, do nothing. Just let it continue!
    }//end of while(true)
    * Print and check the philosophers' state.
    * To insure there are no two philosophers sit side by side
    * are eating at the same time.
    private static void printPher(int[] phers){
    System.out.print(" philosophers' state��");
    for (int i = 0; i < phers.length; i++) {
    System.out.print(" "+phers);
    System.out.println("");
    for (int i = 0; i < phers.length-1; i++) {
    if (phers[i]==EATING && phers[i+1]==EATING){
    System.err.println(i+" and "+(i+1)+"two of philosophers sitted side by side are eating at the same time!");
    if (phers[0]==EATING && phers[PHER_NUM-1]==EATING){
    System.err.println("0 and "+PHER_NUM+"two of philosophers sitted side by side are eating at the same time!");
    public static void main(String[] args) {
    for (int i = 0; i < PHER_NUM; i++) {
    PhilosopherEating.pherState[i] = THINKING;
    PhilosopherEating aPhilosopherEating = new PhilosopherEating();
    for (int i = 0; i < PHER_NUM; i++) {
    philosophers[i] = new Philosopher(i);
    philosophers[i].start();
    try {
    Thread.sleep(30000);
    catch (InterruptedException ex) {
    ex.printStackTrace(System.out);
    //End all the threads of philosophers
    PhilosopherEating.finished = true;

    this problem is about learning how to use threads/synchronise objects etc, the efficiency of the code isn't really an issue, if that's what you mean. As for the efficiency of the solution, it's very hard to tell how efficient it is, but as long as all the philosphers get to eat there's no problem. I haven't really scrutized your code, but I'm not sure that you have a deadlock free solution: as long as it is possible for all the phils to pick up one fork at the same time there's a problem, and it seems from your code that each philosopher will pick up "his" fork. Again, I could be wrong, I haven't really looked. If you haven't come up with a solution, try drawing it on paper and working it out, or if you're lazy a quick google will probably give you the answer, but I'm pretty sure nobody here will :)

  • Execute an external java program with Runtime, problem with classpath

    Hi,
    I m calling an external java program by the command:
    Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
    "java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
    Could anyone give some pointers please?
    Many thanks!
    Edited by: 836590 on 14-Feb-2011 09:03

    836590 wrote:
    Hi,
    I m calling an external java program by the command:
    Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
    "java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
    Could anyone give some pointers please?
    Many thanks!
    Edited by: 836590 on 14-Feb-2011 09:03First, if you run from the command line
    java -classpath "library/*" org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesfrom the parent directory of library, does it work?
    Despite what I said to Kayaman about Runtime.exec not expanding the asterisk, it looks like that's what's happening, so that you're getting
    java -claspath library/aaaa_something_before_antlr.jar library/antlr.jar library/bbb.jar library/ccc.jar  org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesThat is, it *is* expanding the asterisk to a list of files in the directory, and the first one is being taken as the classpath, and the second one--library/antlr.jar is being taken as the class to execute. I'm certain this doesn't happen on Linux, so it must be a Windows thing.
    Two suggestions:
    1) Try single quotes instead of double.
    2) Try the exec that takes an array
    Runtime.getRuntime().exec(new String[] {"java", "-classpath", "'library/*'", "org.mypackage.TestMainProgram", "param1", "c:/input/files", "c:/output/files");Edited by: jverd on Feb 14, 2011 9:41 AM

  • 100% Pure Java Program

    I have seen that the 100% Pure Java Program has "completed the Sun End of Life process and it is no longer supported by Sun" (see http://java.sun.com/100percent/).
    Can anyone explain to me why is this, and what alternatives do we have now to be Java Certified (if any)?
    Thanks.

    It's disturbing but probably not end of the world.
    I like this:
    "Any use of product on this page is at the sole discretion of the developer and Sun assumes no responsiblity for any resulting problems."
    Do they mean that jdk 1.4 is bugless and they are resposible for any problems if something happens?
    I do not think so.

  • Problem while calling a Webservice from a Stand alone java program

    Hello Everyone,
    I am using a java program to call a webservice as follows. For this I have generated the client proxy definition for Stand alone proxy using NWDS.
    Now when I call the method of the webservice I am getting the correct result but along with the result I am getting one error and one warning message in the output.
    The java code to call the webservice is as follows.
    public class ZMATRDESCProxyClient {
         public static void main(String[] args) throws Exception {
              Z_MATRDESC_WSDService ws = new Z_MATRDESC_WSDServiceImpl();
              Z_MATRDESC_WSD port = (Z_MATRDESC_WSD)ws.getLogicalPort("Z_MATRDESC_WSDSoapBinding",Z_MATRDESC_WSD.class);
              String res = port.zXiTestGetMatrDesc("ABCD134");
              System.out.print(res);
    The result I am getting is :
    Warning ! Protocol Implementation [com.sap.engine.services.webservices.jaxrpc.wsdl2java.features.builtin.MessageIdProtocol] could not be loaded (NoClassDefFoundError) !
    Error Message is :com/sap/guid/GUIDGeneratorFactory
    <b>Material Not Found</b> -
    > This is the output of webservice method and it is right.
    Can any one please let me know why I am getting the warning and error message and how can I fix this.
    Thanks
    Abinash

    Hi Abinash,
    I have the same problem. Have you solve that problem?
    I am using a java program to call a webservice too. And I have generated the client proxy definition for Stand alone proxy using NWDS. When I call the method of the webservice I am getting the correct result but along with the result I am getting one error and one warning message in the output.
    The java code to call the webservice is as follows.
    MIDadosPessoaisSyncService service = new MIDadosPessoaisSyncServiceImpl();
    MIDadosPessoaisSync port = service.getLogicalPort("MIDadosPessoaisSyncPort");
    port._setProperty("javax.xml.rpc.security.auth.username","xpto");
    port._setProperty("javax.xml.rpc.security.auth.password","xpto");
    String out = port.MIDadosPessoaisSync("xpto", "xpto");
    System.out.println(out);
    The result I am getting is :
    Warning ! Protocol Implementation [com.sap.engine.services.webservices.jaxrpc.wsdl2java.features.builtin.MessageIdProtocol] could not be loaded (NoClassDefFoundError) !
    Error Message is :com/sap/guid/GUIDGeneratorFactory
    <b>The result of the WS is correct!!!</b>
    The Java project does not have any warning. But the stand alone proxy project has following warnings associated with it.
    This method has a constructor name     MIDadosPessoaisSync.java     
    The import javax.xml.rpc.holders is never used     MIDadosPessoaisSyncBindingStub.java     
    The import javax.xml.rpc.encoding is never used     MIDadosPessoaisSyncBindingStub.java     
    The constructor BaseRuntimeException(ResourceAccessor, String, Throwable) is deprecated     MIDadosPessoaisSyncBindingStub.java
    It is very similar with your problem, could you help me?
    Thanks
    Gustavo Freitas

  • Problem when Running a java program

    I am new to Java. I have installed JDK 1.3.1 on my machine. have setup the class path also. My program complies fine but when i am running it I am getting the following error.
    Exception in thread "main" java.lang.NoClassDefFoundError: InsertSuppliers
    Press any key to continue . . .
    I am pasting my java program underneath. Can anybody please help me?
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    import java.io.*;
    public class InsertSuppliers
         public static void main(String[] args)
    throws IOException
              System.out.println("iuysuiysuidyfsduyf");
              String url = "jdbc:odbc:CafeJava";
              Connection con;
              Statement stmt;
              String query = "select SUP_NAME, SUP_ID from SUPPLIERS";
              try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              } catch(java.lang.ClassNotFoundException e) {
                   System.err.print("ClassNotFoundException: ");
                   System.err.println(e.getMessage());
              try {
                   con = DriverManager.getConnection(url,
                                                 "Admin", "duke1");
                   stmt = con.createStatement();
                   stmt.executeUpdate("insert into SUPPLIERS " +
         "values(49, 'Superior Coffee', '1 Party Place', " +
                        "'Mendocino', 'CA', '95460')");
                   stmt.executeUpdate("insert into SUPPLIERS " +
                        "values(101, 'Acme, Inc.', '99 Market Street', " +
                        "'Groundsville', 'CA', '95199')");
                   stmt.executeUpdate("insert into SUPPLIERS " +
         "values(150, 'The High Ground', '100 Coffee Lane', " +
                        "'Meadows', 'CA', '93966')");
                   ResultSet rs = stmt.executeQuery(query);
                   System.out.println("Suppliers and their ID Numbers:");
                   while (rs.next()) {
                        String s = rs.getString("SUP_NAME");
                        int n = rs.getInt("SUP_ID");
                        System.out.println(s + " " + n);
                   stmt.close();
                   con.close();
              } catch(SQLException ex) {
                   System.err.println("SQLException: " + ex.getMessage());
    }

    Your error occurs because java can not find a file named InsertSuppliers.class in the Classpath. there are 3 basic ways to make this work. Assume you compiled InsertSuppliers so that the InsertSuppliers.class file is in a directory c:\myjava (I am assuming Windows).
    1. Do not set your System Classpath. CD to the c:\myjava directory. Enter "java InsertSuppliers"
    2. Set your System Classpath = .;c:\myjava and enter "java InsertSuppliers" from any directory.
    3. Enter "java -classpath c:\myjava InsertSuppliers" from any directory.
    Of course, none of these will work if InsertSuppliers.class file doesn't exist in c:\myjava. And remember that class names are case sensitive.

  • Problems running a java program

    Hello,
    I have absolutely no java experience whatsoever, and I need to fix a program that suddenly stopped running properly after several years without problems. Basically, I have a perl script that calls a java program. Everytime I run this perl script from the web browser, the java program returns an internal error:
    # # HotSpot Virtual Machine Error, Internal Error # Please report this error at # http://www.blackdown.org/cgi-bin/jdk # # Error ID: 5649525455414C53504143450E4350500024 # # Problematic Thread: prio=5 tid=0x804e680 nid=0x6d16 runnable #
    However, when I run the perl script command line, it runs fine. I added the -verbose option to the java call, and I discovered that the program stops running after it opens the .jar files but before it loads them .... these files have full read permissions, so I don't think that's the problem. Any ideas?
    Thanks!

    ...fix a program that suddenly stopped running properly after several years without problems.Which means either the program changed or the environment changed. I would guess the environment. The most likely possibilities: new version of the operating system, new version of perl, new version of java. Also possible: new version installed of any of the previous without removing older versions, new software not associated with the first, new mapped drives and/or changed env vars.

  • Problem in Creating New position in Siebel CRM 7.8 using java program

    Hi
    We have Siebel CRM with Business Object and Business Component as Position.
    Position Business Component has a manadatory pick list Division.
    When we try to create a new Position by picking the Divison then we are getting the below error
    Logged in OK!
    picking the list
    in the pick() method before
    <Exception>
    <Major No.>256</Major No.><Minor No.>21944</Minor No.><Message>An error has occurred picking the current row.
    Please continue or ask your systems administrator to check your application configuration if the problem persists.(SBL-DAT-00292)</Message><DetailedMessage>Unknown<DetailedMessage>
    <Exception>
    <com.siebel.om.sisnapi.i>
    <Major No.>256</Major No.><Minor No.>21944</Minor No.><Message>An error has occurred picking the current row.
    <Error><ErrorCode>21944</ErrorCode> <ErrMsg>An error has occurred picking the current row.
    Please continue or ask your systems administrator to check your application configuration if the problem persists.(SBL-DAT-00292)</Message><DetailedMessage>Unknown<DetailedMessage>
    Please continue or ask your systems administrator to check your application configuration if the problem persists.(SBL-DAT-00292)</ErrMsg></Error>
    <com.siebel.om.sisnapi.i>
    <Error><ErrorCode>21735</ErrorCode> <ErrMsg>Siebel eScript runtime error occurred in procedure 'BusComp_SetFieldValue' of BusComp [Position]:
    <Error><ErrorCode>21944</ErrorCode> <ErrMsg>An error has occurred picking the current row.
    ConversionError 1616: Undefined and Null types cannot be converted to an object.
    Please continue or ask your systems administrator to check your application configuration if the problem persists.(SBL-DAT-00292)</ErrMsg></Error>
    (SBL-SCR-00141)</ErrMsg></Error>
    <Error><ErrorCode>21735</ErrorCode> <ErrMsg>Siebel eScript runtime error occurred in procedure 'BusComp_SetFieldValue' of BusComp [Position]:
    <Error><ErrorCode>21735</ErrorCode> <ErrMsg>Stack trace:
    BusComp [Position].BusComp_SetFieldValue(), Line: 1110</ErrMsg></Error>
    ConversionError 1616: Undefined and Null types cannot be converted to an object.
    </com.siebel.om.sisnapi.i></Exception>
    (SBL-SCR-00141)</ErrMsg></Error>
    <Error><ErrorCode>21735</ErrorCode> <ErrMsg>Stack trace:
    BusComp [Position].BusComp_SetFieldValue(), Line: 1110</ErrMsg></Error>
    </com.siebel.om.sisnapi.i></Exception>
    at com.siebel.data.SiebelBusComp.pick(SiebelBusComp.java:241)
    at siebelconn.main(siebelconn.java:44)
    Java program
    import com.siebel.data.*;
    import com.siebel.data.SiebelException;
    class siebelconn {
    public static void main (String args [])
    SiebelDataBean m_dataBean = null;
    SiebelBusObject m_busObject = null;
    SiebelBusComp m_busComp = null;
    SiebelBusComp picklistBC = null;
         try{
    m_dataBean = new SiebelDataBean(); //Create Siebel JDB instance
    m_dataBean.login("XXXX", "XXX", "XXX");
         System.out.println("Logged in OK!");
    m_busObject = m_dataBean.getBusObject("Position");
    m_busComp = m_busObject.getBusComp("Position");
    m_busComp.newRecord(false);
    picklistBC = m_busComp.getPicklistBusComp("Division");
    picklistBC.clearToQuery();
    picklistBC.setViewMode(3);
    picklistBC.setSearchSpec("Name", "idmtest");
    //picklistBC.executeQuery(true);
    picklistBC.executeQuery2(true,true);
    if(picklistBC.firstRecord())
    System.out.println("picking the list");
    picklistBC.pick();
    System.out.println("records are there");
    m_busComp.setFieldValue("Name","Access GE HQ 11");
    m_busComp.writeRecord();
    }//if
         if(m_busObject!=null)
    m_busObject.release();
    if(m_busComp!=null)
    m_busComp.release();
    if(picklistBC!=null)
    picklistBC.release();
    if(m_dataBean!=null)
    m_dataBean.logoff();
    catch(Exception e)
    System.out.println(e);e.printStackTrace();
    if(m_busObject!=null)
    m_busObject.release();
    if(m_busComp!=null)
    m_busComp.release();
    if(picklistBC!=null)
    picklistBC.release();
    try
    if(m_dataBean!=null)
    m_dataBean.logoff();
    }catch(Exception e1){System.out.println(e1);}
    Can any body please help us.
    Thanks

    From the error code, it looks like you have a scripting error in the BusComp_SetFieldValue event on the Position
    business component in your application.
    Have you tried to look at that code or to turn of scripting for the application as a total?
    Axel

  • Java Programming Problem

    Hi all,
    I was looking for this java programming problem which had to do with a large building and there was some gallons of water involved in it too somehow and we had to figure out the height of the buiding using java. This problem is also in one of the java books and I really need to find out all details about this problem and the solution. NEED HELP!!
    Thanks
    mac

    Yes, it will. The water will drain from the bottom of
    the tank until the pressure from the water inside the
    tank equals the pressure from the pipe. In other
    words, without a pump, the water will drain out until
    there is the same amount of water in the tank as in
    the pipe The water pressure depends on the depth of the water, not the volume. So once the depth of the water inside the pipe reaches the same depth as the water inside the tank it will stop flowing. This will never be above the height of the tank.
    I found this applet which demonstrates our problem. If you run it you can drag the guy up to the top, when water in his hose reaches the level of the water in the tank it will stop flowing out.

  • Java server program on Linux problem

    Ok, i've written a simple java server using java.nio and have tested it on my windows machine. Then people can connect and it works as it should.
    However, when i run the server on my linux box it starts as it should, but no users can connect to it. Its like the connections never come through to the java program... What can cause this? Some firewall stuff etc?
    I've tested running a server written in C on the same port (both the java and the c server uses TCP) and then people can connect to it without any problems.
    So it seems to be some security thing in java, or in linux in connection with java programs.
    Anyone can enlight me on how to get the java server to work?
    Best wishes

    What version of the JDK are you using, and which linux kernel?
    From the Java Bug Database:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5056395
    Synopsis        nio does not seem to work with Linux kernel 2.6.4 (and probably above)
    Category      java:classes_nio
    Reported Against      1.4.2_04
    Release Fixed      1.5(tiger-rc)� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Please help me in this tough problem in Java...im just new in Java program

    my teacher give this as a problem. so tough. we are just starting and we are now in control structures. please help me to finish this problem. And my problem is...
    Write an astrology program. The user types in his or her birthday(month,day,year),
    and the program responds with the user's zodiac sign, the traits associated with each sign
    the user's age(in years,months,day), the animal sign for the year(e.g., Year of the Pig,
    Year of the Tiger), the traits associated with each animal sign, and if the year is a leap
    year or not. The dates covered for each sign can be searched through the horoscope section
    of a newspaper or through the internet. Then enhance your program so that if the user is one
    or two days away from the adjacent sign, the program outputs the nearest adjacent sign as well
    as the traits associated with the nearest sign. The month may be entered as a number from 1 to 12
    or in words, i.e.,January to December. Limit the year of the birthday from 1900 to 2010 only.
    The program should allow the user to repeat the entire process as often as desired.
    You can use:
    import java.text.DateFormat;
    import java.util.Date;
    import java.util.Calendar;
    please...those who are genius out there in java program...help us to pass this project. Im begging! thanks!

    Frowner_Stud wrote:
    According to the second commandment: Thou shall not use the name of the Lord in vain.Is this not the definition of ironic, Mr. Morality?
    i am not cheating. And more of the same.
    we all know that an assignment is an assignment. a homework. homework means you can raise other help from somebody so that you will know the answer.You're not asking for "help" bucko, because you've been given decent help but have chosen to ignore it. No, you're asking for someone to do the work for you, and you may call it what you want, but in anyone else's book, that's cheating.
    dont be fool enough to reply if you dont know the reason why i am typing here Don't be fool enough to think that you can control who can or can't respond.
    because if you are in my part and if i know the answer there is no doubt that i will help you as soon as possible! Just because you have low morals doesn't mean that the rest of us do.
    Thanks for time of reading and God bless you including you family!and to you and yours. Have a blessed day.

  • Problem with running java program

    Hey again!
    I missed out some information in last posting.. here is the full description
    I have just installed 1.5.0_06 and have set paths and what otherwise is necessary to run the java programs. I was testing the install and run a standard HelloWorld.java program
    I got the following error:
    Exception in thread main java.lang.NoClassDefFoundError: HelloWorld
    what is wrong...
    Here is the entire HelloWorld.java
    public class HelloWorld
    public HelloWorld()
    System.out.println("Hello World");
    public static void main(String[] args)
    HelloWorld hw = new HelloWorld();
    I have checked that the path is correct too..
    Hopefully someone can help me!
    Anders

    Your Path is set, probably the problem is classpath.
    Change the cmd/command prompt to the directory that contains your HelloWorld.class file, verifying that it exists. If it does, issue this command from that directory:
    java -cp . HelloWorld
    Important: include the period and surrounding spaces
    If that works, you can learn about setting and using the classpath here:
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html#general
    By the way, just add a reply to your original post with the additional information, rather than creating another post. That eliminates duplication of replies.

  • Problems Running Java Programs

    I usually use Forte for Java to run and compile my java programs, but now I am trying to compile and run using the command line. When I compile something it runs fine. However when I attempt to run something it gives me a NoClassDefFound Error. For example when I have this program in package greetings.
    D:\JDK_Forte\forte4j\Development>javac greetings\Hello.java
    D:\JDK_Forte\forte4j\Development>java greetings.Hello
    Exception in thread "main" java.lang.NoClassDefFoundError: greetings/Hello
    So it compiles fine but does not run. Is something possibly not set up correctly? I don't know what could be wrong. Thanks for any help you can give.

    try
    D:\JDK_Forte\forte4j\Development>java -classpath .
    greetings.HelloI tried that and I got this error don't know if this helps at all....
    D:\JDK_Forte\forte4j\Development>java -classpath . greetings.Hello
    Exception in thread "main" java.lang.NoClassDefFoundError: greetings/Hello (wron
    g name: Hello)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

  • Is Eclipse a 100% pure Java program?

    Is Eclipse a 100% pure Java program?

    Eclipse runs on linux, windows, MAc OS X and I think a few others. It has native widgets via SWT for those platforms using the native OS Look and Feel. It is smoother than Swing in most ways, yet Swing does have some advantages as well. SWT is a nice kit. It would be nice if the Swing Team took the idea of building a cross platform native GUI kit into the AWT/Swing layer so that Swing was even faster. I think Swing and SWT are great, only I wish Swing had provided what SWT does (in some ways) so that Swing would have been used and SWT never written. It's a shame, but then again, perhaps it promotes the Swing Team to make Swing better/faster.
    Look at Swing on Mac OS X, it is very nice, looks like native OS (because Apple wrote their own L&F for Mac OS X Only), but it is faster than Swing on Windows/Linux.

  • Typical problem in java program ?

    Typical problem in java program ?
    I have three java files , i am pasting them here. Please show me the errors. Compilation error in Cat.java
    File 1 : Dog.java
    public class Dog extends Animal {
    public String noise() { return "back"; }
    File 2 : Cat.java
    public class Cat extends Animal {
    public String noise() {
    return "meow";
    File 3:AnimalTest.java
    public class AnimalTest {
    public static void main(String[] args)
    Animal animal = new Dog();
    //Cat cat = (Cat)animal;
    Cat cat = new Cat();
    System.out.println(cat.noise()...
    Output :
    D:\>javac AnimalTest.java
    .\Cat.java:4: illegal start of expression
    ^
    .\Cat.java:5: ';' expected
    ^
    .\Cat.java:5: '}' expected
    ^
    3 errors
    Please help me. Not a homework.
    Message was edited by:
    Taton

    D:\>javac AnimalTest.java
    .\Cat.java:4: illegal start of expression
    ^You really need to start to understand what you are doing. Look at the error, it even points to what the error is. Look at where this bracket appears in your code and think to yourself "Should that be there or should it be something else" Once you fix that, the other errors will probably disappear.
    Stoopid lag.
    Message was edited by:
    flounder

Maybe you are looking for

  • How to convert the date time from MM-DD-YYYThh:mm:ss to YYYY-MM-DDThh:mm:ss format

    Hi All, I have a requirement in my project like to convert the date time from one format to another.my situation is like to convert the date time from MM-DD-YYYThh:mm:ss to YYYY-MM-DDThh:mm:ss format. I am using the soa suite 11.1.1.6. Can any one su

  • Convert static html page to portal help needed

    I have a page here. that I need to put in portal. I am having trouble! use banner for the top image. use a region for the top menu links. This is "About, Registration, Security,etc...) Because menu bars and folders do not do horizontal alignment of i

  • IPad 2 Bluetooth Setting cannot be turned on

    My bluetooth setting is set to off, but the slide option to turn it on is missing.  Instead there is only the circle hourglass like it is searching for something.  I noticed this right after trying to pair to a device that was aleady paired to my iPo

  • TVSU "an error occurred while gathering user information"

    I am getting this error on E20 4220CTO. I was told by tech support one/some of the windows files were bad and that was why it didn't run. I don't believe that response as everything else works just fine--except TVSU--and the tech gave me no idea whic

  • Power book uses?

    im looking to by an apple computer and use it for film editing. i was going to purchase a G5 but now im thinking of getting a power book G4, im wondering if it is a good choice for running final cut studio, and if i will be able to hook my sony camco