How can i invoke a void method in main?

Hi guys I am killing myself over why we use void method if we can't call on it from main.
For example i am trying to create a program to calculate military time. In my main i am trying to call setHour which is void. setHour is supose to check if the input of hour is over 24 and if it is i have to reset hour to 00. But it gives an error that i can't call on that method because it is void.
So how do i invoke it from main?
and
Why do we use void if we can't call on it?
Thanks

ok here it is mate. It is not finished but pay attention on the setMethods that is what im trying to invoke from main. Here's my methods and then main will be under it.
public class MilitaryTime
      private int hour;
      private int minute;
      private int second;
       public MilitaryTime()
         hour=0;
         minute=0;
         second=0;
       public MilitaryTime(int hour, int minute, int second)
         this.hour=hour;
         this.minute=minute;
         this.second=second;
       public MilitaryTime(MilitaryTime t)
       public void setHour(int h)
         if(h>=24)
            h=00;
         else
            hour=h;
       public void setMinute(int m)
         if(m>=60)
            m=00;
         else
            minute=m;
       public void setSecond(int s)
         if(s>=60)
            s=00;
         else
            second=s;
       public int getHour()
         return hour;
       public int getMinute()
         return minute;
       public int getSecond()
         return second;
       public void tick()
         second=second+1;
       public String toUniversalString()
         StringBuffer     buffer;
         buffer = new StringBuffer();
      // add the hour (with leading zero if its neccesary)
         if(this.hour < 10)
            buffer.append("0");
         buffer.append(this.hour).append(":");
      // add the minute (with leading zero if its neccesary)
         if(this.minute < 10)
            buffer.append("0");
         buffer.append(this.minute).append(":");
      // add the second (with leading zero if its neccesary)
         if(this.second < 10)
            buffer.append("0");
         buffer.append(this.second).append("");
         return buffer.toUniversalString();
       public String toString()
         StringBuffer     buffer;
         buffer = new StringBuffer();
      // add the hour (with leading zero if its neccesary)
         if(this.hour < 10)
            buffer.append("0");
         buffer.append(this.hour).append(":");
      // add the minute (with leading zero if its neccesary)
         if(this.minute < 10)
            buffer.append("0");
         buffer.append(this.minute).append(":");
      // add the second (with leading zero if its neccesary)
         if(this.second < 10)
            buffer.append("0");
         buffer.append(this.second).append("");
         return buffer.toString();
   }Here is main where i try and call setHour to check for accuracy.
import javax.swing.*;
public class TestMilitaryTime
     public static void main(String[]args)
                    String sHour=JOptionPane.showInputDialog(null,
            "Input Hour:", "Military Time",JOptionPane.QUESTION_MESSAGE);
                    int hour=Integer.parseInt(sHour);
                    String sMinutes=JOptionPane.showInputDialog(null,
            "Input minutes:", "Military Time",JOptionPane.QUESTION_MESSAGE);
                    int minutes=Integer.parseInt(sMinutes);
                    String sSeconds=JOptionPane.showInputDialog(null,
            "Input seconds:", "Military Time",JOptionPane.QUESTION_MESSAGE);
                    int seconds=Integer.parseInt(sSeconds);
                    MilitaryTime time= new MilitaryTime(hour,minutes,seconds);
                    System.out.println(time.setHour());
                    System.out.println("The military time is you enterd is "+time.toString());
     Everything else works fine except the setHour thing.
Thanks

Similar Messages

  • How can i invoke the set method before value change listener?

    Hi,
    My code is like this:
    <af:selectManyCheckbox value="#{bean.statusList}"
                                     binding="#{bean.statusCheckBox}"
                                     label=" " autoSumit="true"
                                     valueChangeListener="#{bean.changeStatusList}"
                                     id="dc_smc1" layout="vertical"">
                <f:selectItems value="#{bean.statusBuckets}"
                               id="statusBuckets"/>
              </af:selectManyCheckbox>
    public void changeStatusList(ValueChangeEvent valueChangeEvent)
      //in this method, i want to set the statusList by myself, this is not the same with the ui.
    public void setStatusList(List<String> statusList)
            this.statusList = statusList;
        public List<String> getStatusList()
            return statusList;
    As i set the autoSumit="true", then no matter what i set the statusList in the method changeStatusList, it will be reset the value after invoke the method setStatusList, Therefore, it will always change the checkbox status through ui operation, i cannot change it through code.
    Pl help me!
    Thanks,
    Emma

    Emma, which jdev version do you use?
    As you have set the value property to the list you try to change in the valueChangeListener method this is expected behavior. If the list is bound to the af:selectManyCheckbox values you can't change it with a set method.
    It would help if you tell us what you are trying to do in a broader scope.
    Timo

  • Class.forName how can I invoke a unknown method

    I have a code like this:
    public class Detonator {
    String cName;
    String mName;
    public Detonator(String className, String methodName) {
    cName = className;
    mName = methodName;
    // in this place I want to do something like cName.mName()
    // Is it possible ???
    }

    Look at java.lang.reflect.*.

  • How can one invoke a WebLogic EJB from a BPEL Server hosted on OC4J?

    How can one invoke a WebLogic EJB from a BPEL Server hosted on OC4J?
    Reason I ask is I keep getting this error:
    javax.naming.NoInitialContextException: Cannot instantiate cla
    ss: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotF
    oundException: weblogic.jndi.WLInitialContextFactory]
    Note: I am using <bpelx:exec> as a way to execute some java program.
    Essentially my java client (essentially an EJB client hosted on Oc4J) needs access to wlclient.jar since it needs access to weblogic.jndi.WLInitialContextFactory. I have a EJB client running on BPEL server hosted on Oc4J that needs to access some EJBs hosted on weblogic.
    Where do I place this wlclient.jar so that BPEL PM can start peacefully and at runtime discover the InitialContextFactory classes?
    Placing it in the j2ee/home/applib doesn't solve the problem. The server fails to start up if I do this
    I tried placing it in BPEL-INF\lib directory ...
    I still get the same exception...see below for exception dump
    I verified the BPEL suitcase, and it in fact does contain the jar file wlclient.jar
    integration\orabpel\domains\default\deploy contains the bpel_BPELProcess2_1.0.jar file and snapshot of that is as follows:
    <PRE>
    &#9474; bpel.xml
    &#9474; BPELProcess2.bpel
    &#9474; BPELProcess2.jpr
    &#9474; BPELProcess2.wsdl
    &#9474; bpel_BPELProcess2_1.0.jar
    &#9474; build.xml
    &#9474; buildxml.copy
    &#9474; graphics.xml
    &#9474;
    &#9500;&#9472;&#9472;&#9472;BPEL-INF
    &#9474; &#9492;&#9472;&#9472;&#9472;lib
    &#9474; myEJB.jar
    &#9474; wlclient.jar
    &#9474;
    &#9500;&#9472;&#9472;&#9472;META-INF
    &#9474; MANIFEST.MF
    &#9474;
    &#9492;&#9472;&#9472;&#9472;output
    bpel_BPELProcess2_1.0.jar
    </PRE>
    I tried using the BPEL-INF\jar directory...Is this something the obant automatically detects? or do I have to modify the build.xml? I created this directory and let Jdev deploy to local BPEL server->default domain handle it
    #####################3
    I even tried copying the wlclient.jar to
    integration\orabpel\system\classes but this doesn't help since the BPEL PM fails to start if I explode this jar into this directory.
    In short,where do I place the wlclient.jar so that this exception can be contained.
    I edited the build.xml to point to the jar, that too didn't work, unless I made some mistake in the file
    <bpelc classpath="${basedir}/BPEL-INF/classes;${home}/system/classes;${home}/lib/j2ee_1.3.01.jar;${basedir}/BPEL-INF/jar/wlclient.jar" input="${basedir}/bpel.xml" rev="${rev}" deploy="${deploy}" />
    </target>
    </project>
    DETAILS on ERROR
    I get the following error
    Process "BPELProcess2" (revision "1.0") successfully compiled.
    <2005-12-14 09:17:55,770> <INFO> <default.collaxa.cube.engine.deployment> Proces
    s "BPELProcess2" (revision "1.0") successfully loaded.
    05/12/14 09:18:36 weblogic.jndi.WLInitialContextFactory
    javax.naming.NoInitialContextException: Cannot instantiate cla
    ss: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotF
    oundException: weblogic.jndi.WLInitialContextFactory]
    05/12/14 09:18:36 at javax.naming.spi.NamingManager.getInitialContext(Nami
    ngManager.java:652)
    05/12/14 09:18:36 at javax.naming.InitialContext.getDefaultInitCtx(Initial
    Context.java:243)
    05/12/14 09:18:36 at javax.naming.InitialContext.init(InitialContext.java:
    219)
    05/12/14 09:18:36 at javax.naming.InitialContext.<init>(InitialContext.jav
    a:195)
    05/12/14 09:18:36 at com.ejb.test.MapFinder.getDefaultMapName(Map
    Finder.java:37)
    ##################3
    with the bpelx all I have is two lines of code that creates a java object and calls a method on it.
    The method does this:
        private String initialContextFactory = "weblogic.jndi.WLInitialContextFactory";
        private String providerUrl = "t3://localhost:7001";
        private String urlPkgPrefixes = "";
        private String mapEjbJndiName = "ejb/mycompany/Redlands";
        public String getDefaultMapName() {
          try {
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY, getInitialContextFactory());
              env.put(Context.PROVIDER_URL, getProviderUrl());
              if (getUrlPkgPrefixes() != null && !getUrlPkgPrefixes().equals(""))
                  env.put(Context.URL_PKG_PREFIXES, getUrlPkgPrefixes());
              System.out.println("    " + getInitialContextFactory());
              System.out.println("    " + getProviderUrl());
              System.out.println("    " + getUrlPkgPrefixes());
              System.out.println("    " + getEjbName());
              // Get a naming context
              context = new InitialContext(env);
               Object ms  = context.lookup(getEjbName());
              MyEJBHome home = (MyEJBHome ) PortableRemoteObject.narrow(ms, MyEJBHome.class);
              myEjb = home.create();
              return myEjb.getDefaultName();
          } catch (RemoteException re){
              System.out.println(re.getCause().getMessage());
          catch (Exception ex) {
              ex.printStackTrace();
          return null; //if unable to resolve the context factory etc...
        }

    I did exactly as you suggested. I edited the application.xml and added this
    <library path="C:\ArcGIS\test\bea\wlclient.jar"/>
    I didn't add weblogic because the needed classes were all in wlclient.jar
    I also edited the BASE_OB_CLASSPATH to include this jar.
    Here is the result when I just start BPEL PM Server. Somehow BPEL PM doesn't like to have wlclient.jar in its classpath during startup.
    Failed to create "worker" bean; exception reported is: "javax.naming.NameNotFoun
    dException: remaining name: env
    at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:49)
    at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
    at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at com.collaxa.cube.engine.ejb.impl.WorkerBean.ejbCreate(WorkerBean.java
    :49)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.evermind.server.ejb.MessageDrivenHome.getInstance(MessageDrivenHo
    me.java:1235)
    at com.evermind.server.ejb.MessageDrivenHome$2.run(MessageDrivenHome.jav
    a:1150)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(Relea
    sableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)
    <2005-12-29 13:39:05,281> <ERROR> <collaxa> <ServerManager::loadAllDomains>
    ORABPEL START-UP ERROR!!!!!!!!
    OraBPEL run-time system failed to start due to exception:
    Could not initialize jms connection pool.
    Could not initialize connection pool for connection factory "java:comp/env/jms/
    ollaxa/BPELInvokerQueueFactory"; the reason is remaining name: env/jms/collaxa/
    PELInvokerQueueFactory.
    Note: So what I did was to removed the entry from application.xml and tried with just obsetenv.bat having the wlclient.jar added to it. This too failed!!
    Here is a snapshot of the error I got.
    Process "BPELProcess2" (revision "1.0") successfully compiled.
    <2005-12-29 13:53:11,207> <INFO> <default.collaxa.cube.engine.deployment> Proces
    s "BPELProcess2" (revision "1.0") successfully loaded.
    05/12/29 13:53:32 Cannot instantiate class: weblogic.jndi.WLInitialContextFactor
    y
    05/12/29 13:53:32 javax.naming.NoInitialContextException: Cannot instantiate cla
    ss: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotF
    oundException: weblogic.jndi.WLInitialContextFactory]
    05/12/29 13:53:32 at javax.naming.spi.NamingManager.getInitialContext(Nami
    ngManager.java:652)
    05/12/29 13:53:32 at javax.naming.InitialContext.getDefaultInitCtx(Initial
    Context.java:243)
    05/12/29 13:53:32 at javax.naming.InitialContext.init(InitialContext.java:
    219)
    05/12/29 13:53:32 at javax.naming.InitialContext.<init>(InitialContext.jav
    a:195)
    05/12/29 13:53:32 at com.esri.adf.ejb.test.MapFinder.getDefaultMapName(Map
    Finder.java:57)
    05/12/29 13:53:32 at bpel.p0.ExecLetBxExe1.execute(ExecLetBxExe1.java:62)
    05/12/29 13:53:32 at com.collaxa.cube.engine.ext.wmp.BPELXExecWMP.__execut
    eStatements(BPELXExecWMP.java:49)
    05/12/29 13:53:32 at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perfo
    rm(BPELActivityWMP.java:185)
    05/12/29 13:53:32 at com.collaxa.cube.engine.CubeEngine.performActivity(Cu
    beEngine.java:3398)
    05/12/29 13:53:32 at com.collaxa.cube.engine.CubeEngine.handleWorkItem(Cub
    eEngine.java:1905)
    05/12/29 13:53:32 at com.collaxa.cube.engine.dispatch.message.instance.Per
    formMessageHandler.handleLocal(PerformMessageHandler.java:75)
    05/12/29 13:53:32 at com.collaxa.cube.engine.dispatch.DispatchHelper.handl
    eLocalMessage(DispatchHelper.java:100)
    05/12/29 13:53:32 at com.collaxa.cube.engine.dispatch.DispatchHelper.sendM

  • How do i get a list of all Roles defubed under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?

     

    Sorry for the typographical mistake.
    Please read the question as:"How do i get a list of all Roles defined under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?"

  • How can I invoke the web service manually in websphere?

    Hi
    I've developed a webservice application using Rational Application Developer (RAD). I deployed it in a websphere 6.1 application server, using the administration console to import the war file that I had previously exported with RAD.
    My webservice application is listed in the "Enterprise Applications" section of websphere's administration console as started.
    My question is: how can I invoke the web service manually? Is there some kind of websphere generated webpage that I can use to call it manually?
    I tried http://<server:port>/<contextroot> and http://<server:port>/<contextroot>/<servicename> in a webbrowser, but it doesn't work. Is it possible to invoke the web service manually, or do I need to develop a client?
    Thanks in advance
    Pedro

    Hi Bo Wang,
        Go to the Portal -> System Administration -> System Configuration
                               -> Portal Content folder
                               -> Open Visual Composer folder
        There you can see the Webservice Systems you have created through VC.
    You can delete the unwanted system here.
    Regards,
    Shemim

  • How can i use Catalog in Method Type?

    Dear Experts,
    How can i use Catalog in Method Type?
    I want to use Multiple method type mean require selection option(help from catalog)and also need to entere the result against certain parameters. So how can i do this possible ?
    Except use of additional infrmation field
    Regards,
    Abhishek

    Hi,
    Can i provide selection option F4 help at Method while enteing the result?
    Because for 1 MIC as per buyer method testing different so it will come alternately.
    i.e i have 3 methods which comes altarnative for one MIC
    TST_ISO
    TST_AATC
    TST_ASTM
    So how it is possible???

  • How can I call the create method in BO from Application Service

    Hello!
    When I create a Business Object, CAF generates some methods automatically.
    How can I call the create method in the BO from Application Service logic?
    When i call the method then the entityManager and the sessionContext is NULL.
    How can I initialize this?
    Can anybody help me?
    Thanks, Thomas

    If you are using CE 7.11...
    1) In the Application Services, add the BO as dependant object in dependencies tab.
    2) In the implemention, add the following codes to call create method of the BO:
    this.get<BO>.createMethod();
    julius

  • How can i deprecate a superclass method ?

    Hi all,
    How can i deprecate a superclass method from a subclass

    Qthe OP: That makes no sense. It is by definition valid to call that method because it is valid for the superclass, and every instance of the subclass is also an instance of the superclass.

  • How can i invoke a file chooser dialog box with out using input type=file

    how can i invoke a file chooser dialog box with out using <input type=file> can any one help me mail me to [email protected]

    You could use an applet...
    Or maybe Javascript has some way to do it.

  • How can I change the payment method to None with gift card balance.

    How can I change the payment method to None with gift card balance?
    I already have an Apple ID account with no credit card but when I try to log in download free app it says Apple ID has not been used in iTunes store please review your account and it appears the billing info and there's no none in the option..how can I solve this so that I can used my Apple ID and can download free apps?

    Hi ..
    Help here >  Why can’t I select None when I edit my payment information?HHi

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • How can i execute Spaces API in java main class?

    Hi
    I am able to execute Spaces API through portal application. However if i try to execute it in java main class, its throwing an exception
    "SEVERE: java.io.FileNotFoundException: .\config\jps-config.xml (The system cannot find the path specified)"
    oracle.wsm.common.sdk.WSMException: WSM-00145 : Keystore location or path can not be null or empty; it must be configured through JPS configuration or policy configuration override.
    How can i set this path, so that i can execute Spaces API from java main class.
    Need this main class to configure in cron job, to schedule a task.
    Regards
    Raj

    Hi Daniel
    Currently i have implemented create functionality in my portal application using Spaces API, which is working fine. Now the requirement is, i need to implement a "Cron Job" to schedule a task, which will execute to create space(for example once in a week). Cron job will execute only the main method. So I have created java main class, in which I have used Spaces API to perform create space operation. Then it was giving exception.
    Later I understood the reason, as I am executing the Space API with a simple JSE client, its failing since a simple java program has no idea of default-keystore.jks, jps-config.xml, Security Policy. Hence i have included those details in main class. Now I am getting new error,
    SEVERE: WSM-06303 The method "registerListener" was not called with required permission "oracle.wsm.policyaccess"
    For your reference i have attached the code below, please help. How can i use Spaces API in java main method(i mean public static void main(String[] args) by giving all required information.
        public static void main(String[] args) throws InstantiationException,
                                                      GroupSpaceWSException,
                                                      SpacesException {
            Class2 class2 = new Class2();
            GroupSpaceWSContext context = new GroupSpaceWSContext();
            FactoryFinder.init(null);
            context.setEndPoint("http://10.161.226.30/webcenter/SpacesWebService");
            context.setSamlIssuerName("www.oracle.com");
            context.setRecipientKeyAlias("orakey");
            Properties systemProps = System.getProperties();
            systemProps.put("java.security.policy","oracle/wss11_saml_or_username_token_with_message_protection_client_policy");
            systemProps.put("javax.net.ssl.trustStore","C:\\Oracle\\Middleware11.1.7\\wlserver_10.3\\server\\lib\\cacerts.jks");
    systemProps.put("oracle.security.jps.config","C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\jps-config.xml");
            systemProps.put("javax.net.ssl.keyStore",C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\consumer.jks");
            systemProps.put("javax.net.ssl.keyStorePassword", "Test12");
            System.setProperties(systemProps);
            GroupSpaceWSClient groupSpaceWSClient;
            try {
                groupSpaceWSClient = new GroupSpaceWSClient(context);
                System.out.println("URL: " +
                                   groupSpaceWSClient.getWebCenterSpacesURL());
                //delete the Space
                List<String> groupSpaces = groupSpaceWSClient.getGroupSpaces(null);
                System.out.println("GroupSpaces:: " + groupSpaces.size());
            } catch (Exception e) {
    Regards
    Raj

  • How can we delete the icloud accounts from main website.Iam trying to log in to my account and it says that MAXIMUM NUMBER OF FREE ACCOUNTS ARE ACTIVATED?What can i do guys plz tell me?

    How can we delete the icloud accounts from main website.Iam trying to log in to my account and it says that MAXIMUM NUMBER OF FREE ACCOUNTS ARE ACTIVATED?What can i do guys plz tell me?

    You can't delete an account, you can only stop using it.  If you're getting that error message you won't be able to create a new account on your device.  Your only options are to re-use one of the accounts previously created, or create a new account on a different iOS device or Mac (running OS X Lion or higher), if you have one.

  • My screen on the touch is frozen. the screen shows a usb cable and the itunes logo above it. How can I get it back to the main screen?

    My screen on the touch is frozen. the screen shows a usb cable and the itunes logo above it. How can I get it back to the main screen

    The screen is telling you to connect the iPod to a computer with iTunes via the USB cable.  iTunes should open and give you instructions.  If not, open iTunes and retore the iPod via iTunes.

Maybe you are looking for