Public static void main

Hi all
whether public static void main(String[] a) will execute

Clem1986 wrote:
it's an incomplete sentence, it's just a clause; possible endings:
whether public static void main(String[] a) will execute remains a mystery.*
whether public static void main(String[] a) will execute is determinable.*
whether public static void main(String[] a) will execute is propesterous to ponder.*
whether public static void main(String[] a) will execute is heretical in nature.*
whether public static void main(String[] a) will execute is not a sentence.*
Or start clauses,
_'Tis idiotic to wonder_ whether public static void main(String[] a) will execute.whether public static void main(String[] a) will execute or not, I'm still getting out of my skull tonight

Similar Messages

  • How to call java with public static void main(String[] args) throws by jsp?

    how do i call this from jsp? <%spServicelnd temp = new spServicelnd();%> does not work because the program has a main. can i make another 2nd.java to call this spServiceInd.java then call 2nd.java by jsp? if yes, how??? The code is found below...
    import java.net.MalformedURLException;
    import java.io.IOException;
    import com.openwave.wappush.*;
    public class spServiceInd
         private final static String ppgAddress = "http://devgate2.openwave.com:9002/pap";
         private final static String[] clientAddress = {"1089478279-49372_devgate2.openwave.com/[email protected]"};
    //     private final static String[] clientAddress = {"+639209063665/[email protected]"};
         private final static String SvcIndURI = "http://devgate2.openwave.com/cgi-bin/mailbox.cgi";
         private static void printResults(PushResponse pushResponse) throws WapPushException, MalformedURLException, IOException
              System.out.println("hello cze, I'm inside printResult");
              //Read the response to find out if the Push Submission succeded.
              //1001 = "Accepted for processing"
              if (pushResponse.getResultCode() == 1001)
                   try
                        String pushID = pushResponse.getPushID();
                        SimplePush sp = new SimplePush(new java.net.URL(ppgAddress), "SampleApp", "/sampleapp");
                        StatusQueryResponse queryResponse = sp.queryStatus(pushID, null);
                        StatusQueryResult queryResult = queryResponse.getResult(0);
                        System.out.println("Message status: " + queryResult.getMessageState());
                   catch (WapPushException exception)
                        System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")");
                   catch (MalformedURLException exception)
                        System.out.println("*** ERROR - MalformedURLException (" + exception.getMessage() + ")");
                   catch (IOException exception)
                        System.out.println("*** ERROR - IOException (" + exception.getMessage() + ")");
              else
                   System.out.println("Message failed");
                   System.out.println(pushResponse.getResultCode());
         }//printResults
         public void SubmitMsg() throws WapPushException, IOException
              System.out.println("hello cze, I'm inside SubmitMsg");          
              try
                   System.out.println("hello cze, I'm inside SubmitMsg (inside Try)");                         
                   //Instantiate a SimplePush object passing in the PPG URL,
                   //product name, and PushID suffix, which ensures that the
                   //PushID is unique.
                   SimplePush sp = new SimplePush(new java.net.URL(ppgAddress), "SampleApp", "/sampleapp");
                   //Send the Service Indication.
                   PushResponse response = sp.pushServiceIndication(clientAddress, "You have a pending Report/Request. Please logIn to IRMS", SvcIndURI, ServiceIndicationAction.signalHigh);
                   //Print the response from the PPG.
                   printResults(response);
              }//try
              catch (WapPushException exception)
                   System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")");
              catch (IOException exception)
                   System.out.println("*** ERROR - IOException (" + exception.getMessage() + ")");
         }//SubmitMsg()
         public static void main(String[] args) throws WapPushException, IOException
              System.out.println("hello cze, I'm inside main");
              spServiceInd spsi = new spServiceInd();
              spsi.SubmitMsg();
         }//main
    }//class spServiceInd

    In general, classes with main method should be called from command prompt (that's the reason for main method). Remove the main method, put the class in a package and import the apckage in your jsp (java classes should not be in the location as jsps).
    When you import the package in jsp, then you can instantiate the class and use any of it's methods or call the statis methods directly:
    <%
    spServiceInd spsi = new spServiceInd();
    spsi.SubmitMsg();
    %>

  • Why can't created an object in the "public static void main(String args[])"

    Example:
    public Class Exp {
    public static void main(String args[])
    new Exp2();-------------> To Occur Error
    Class Exp2 {
    public Exp2()

    You can't create an inner class within main, because
    it is a static method. Inner classes can only be
    created by true class methods.This is not correct. You can create an inner class object in a static method. You just have to specify an outer class object that the inner class object should be created within:
    Exp2 exp2 = new Exp().new Exp2();

  • How can i pass the values to method public static void showBoard(boolean[][

    I need x and y to pass to the method
    public static void showBoard(boolean[][] board
    i am very confused as to why its boolean,i know its an array but does that mean values ar true or false only?Thanks
    import java.util.Random;
    import java.util.Scanner;
    public class Life1
         public static void main(String[] args)
              int x=0;
              int y=0;
              Scanner keyIn = new Scanner(System.in);
              System.out.println("Enter the first dimension of the board : ");
              x = keyIn.nextInt();
              System.out.println("Enter the second dimension of the board : );
              y = keyIn.nextInt();
              boolean[][] board = new boolean[x][y];
              fillBoard(board);
              showBoard(board);
              //Ask the user how many generations to show.
              board = newBoard(board);
              showBoard(board);
         //This method randomly populates rows 5-9 of the board
         //Rewrite this method to allow the user to populate the board by entering the
         //coordinates of the live cells.  If the user requests that cell 1, 1 be alive,
         //your program should make cell 0,0 alive.
         public static void fillBoard(boolean[][] board)
              int row, col, isAlive;
              Random picker = new Random();
              for(row = 4; row < 9; row++)
                   for(col = 4; col < 9; col++)
                        if (picker.nextInt(2) == 0)
                          board[row][col] = false;
                        else
                          board[row][col] = true;
         //This method displays the board
         public static void showBoard(boolean[][] board)
              int row, col;
              System.out.println();
              for(row=0; row < x; row++)
                   for(col=0; col<y; col++)
                        if (board[row][col])
                             System.out.print("X");
                        else
                             System.out.print(".");
                   System.out.println();
              System.out.println();
         //This method creates the next generation and returns the new population
         public static boolean[][] newBoard(boolean[][] board)
              int row;
              int col;
              int neighbors;
              boolean[][] newBoard = new boolean[board.length][board[0].length];
              makeDead(newBoard);
              for(row = 1; row < board.length-1; row++)
                   for(col = 1; col < board[row].length-1; col++)
                        neighbors = countNeighbors(row, col, board);
                        //make this work with one less if
                        if (neighbors < 2)
                             newBoard[row][col]=false;
                        else if (neighbors > 3)
                             newBoard[row][col] = false;
                        else if (neighbors == 2)
                             newBoard[row][col]= board[row][col];
                        else
                             newBoard[row][col] = true;
              return newBoard;
         //This method counts the number of neighbors surrounding a cell.
         //It is given the current cell coordinates and the board
         public static int countNeighbors(int thisRow, int thisCol, boolean[][] board)
              int count = 0;
              int row, col;
              for (row = thisRow - 1; row < thisRow + 2; row++)
                   for(col = thisCol - 1; col < thisCol + 2; col++)
                     if (board[row][col])
                          count++;
              if (board[thisRow][thisCol])
                   count--;
              return count;
         //This method makes each cell in a board "dead."
         public static void makeDead(boolean[][] board)
              int row, col;
              for(row = 0; row < board.length; row++)
                   for(col = 0; col < board[row].length; col++)
                        board[row][col] = false;
    }

    this is what im workin with mabey you can point me in the right directionimport java.util.Random;
    /* This class creates an application to simulate John Conway's Life game.
    * Output is sent to the System.out object.
    * The rules for the Life game are as follows...
    * Your final version of the program should explain the game and its use
    * to the user.
    public class Life
         public static void main(String[] args)
              //Allow the user to specify the board size
              boolean[][] board = new boolean[10][10];
              fillBoard(board);
              showBoard(board);
              //Ask the user how many generations to show.
              board = newBoard(board);
              showBoard(board);
         //This method randomly populates rows 5-9 of the board
         //Rewrite this method to allow the user to populate the board by entering the
         //coordinates of the live cells.  If the user requests that cell 1, 1 be alive,
         //your program should make cell 0,0 alive.
         public static void fillBoard(boolean[][] board)
              int row, col, isAlive;
              Random picker = new Random();
              for(row = 4; row < 9; row++)
                   for(col = 4; col < 9; col++)
                        if (picker.nextInt(2) == 0)
                          board[row][col] = false;
                        else
                          board[row][col] = true;
         //This method displays the board
         public static void showBoard(boolean[][] board)
              int row, col;
              System.out.println();
              for(row=0; row < 10; row++)
                   for(col=0; col<10; col++)
                        if (board[row][col])
                             System.out.print("X");
                        else
                             System.out.print(".");
                   System.out.println();
              System.out.println();
         //This method creates the next generation and returns the new population
         public static boolean[][] newBoard(boolean[][] board)
              int row;
              int col;
              int neighbors;
              boolean[][] newBoard = new boolean[board.length][board[0].length];
              makeDead(newBoard);
              for(row = 1; row < board.length-1; row++)
                   for(col = 1; col < board[row].length-1; col++)
                        neighbors = countNeighbors(row, col, board);
                        //make this work with one less if
                        if (neighbors < 2)
                             newBoard[row][col]=false;
                        else if (neighbors > 3)
                             newBoard[row][col] = false;
                        else if (neighbors == 2)
                             newBoard[row][col]= board[row][col];
                        else
                             newBoard[row][col] = true;
              return newBoard;
         //This method counts the number of neighbors surrounding a cell.
         //It is given the current cell coordinates and the board
         public static int countNeighbors(int thisRow, int thisCol, boolean[][] board)
              int count = 0;
              int row, col;
              for (row = thisRow - 1; row < thisRow + 2; row++)
                   for(col = thisCol - 1; col < thisCol + 2; col++)
                     if (board[row][col])
                          count++;
              if (board[thisRow][thisCol])
                   count--;
              return count;
         //This method makes each cell in a board "dead."
         public static void makeDead(boolean[][] board)
              int row, col;
              for(row = 0; row < board.length; row++)
                   for(col = 0; col < board[row].length; col++)
                        board[row][col] = false;
    }

  • Why ..we have to use this ? public static void ? please !

    hi ...im ibrahim ..and im new here in java nd new in the forum too ...nd please i would like to know ...why
    do we use the method
    public static void main (String []args)
    i mean why ..static nd why public ..why void ....why main ..nd why (string []args)
    ...why we use it ...always ....hopefully ..im looking for a very clear answer to this ...issue ..?
    please help .......!

    public - this is the visibility modifier (it means that the body method can be call by any outside method)
    static - the method is a static instance of the class. Not sure what exactly it does though.
    void - this is the return type. void means that the method returns nothing.
    main - the name of the method. It can be anything.
    "public static void main" - this is the main method where upon executing the Java program the Java Virtual Machine will try to locate this method within the specifies class to be executed. This is always the first one to run when executing a Java program. None of this word may be changed or the program cannot be run.

  • Private static void main(String args[]) ... ?????

    even if the main method is declared
    private static void main(String args[])
    //Code Here
    it works fine..can somebody explain the reason behind?

    hi rkippen
    so u mean, since the JVM is calling the main it can
    break all kinds of access specifiers to any class..am
    i right?
    This could be the case.
    However, I tried using 1.4.1 with no development environment (just java.exe) and it gave the following error:
    C:\>java MainTest
    Main method not public.
    So, your development environment might be the cause (e.g. what you use to program your code (e.x. JBuilder)), or the Java version.
    Your development environment might be using reflection to get around Java accessibility checks. For debugging purposes, it is possible to use reflection to obtain refereneces to private methods/fields and invoke those methods and access those fields.
    E.g.
    Vector v = new Vector();
    Field f = v.getClass().getDeclaredField("elementCount");
    f.setAccessible(true); // this is the trick
    f.set(v, new Integer(100));In the presence of a security manager, the setAccessible method will fire a "suppressAccessChecks" permission check.

  • Public static void vs. public static int

    hey java_experts,
    we're learning arrays and i was just wondering whats the difference between public static void vs. public static int

    hi i want to do java mail but i am new in this field
    so please suggest me how i have to get help for the
    java mailNext time start your own thread.
    Google for Java mail tutorial.

  • Jnlp main class: static void main() or applet class????

    When create jnlp file for applet, I have to specify main class. This "main class", is it the class that contain static void main(), or the applet class. The way I design is the that the applet class will SwingUtilities.InvokeAndWait the "main class".
    Should I specify main class when jar the files or in jnlp file?
    Lastly, when I upload my jnlp file to my web server, and try to access it through a web browser, it keeps saying that the web address is invalid. Do I need any special permission from the web server to run jnlp file?
    Thank you and have a wonderful day

    Subject: jnlp main class: static void main() or applet class????
    Note that one '?' denotes a question, wile two or more often denotes a dweeb.
    yunaeyes wrote:
    When create jnlp file for applet, I have to specify main class. This "main class", is it the class that contain static void main(), or the applet class.That depends on whether the JNLP you did not think to add, declares an [<application-desc>|http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html#application_desc] or [<applet-desc>|http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html#applet_desc].
    .. The way I design is the that the applet class will SwingUtilities.InvokeAndWait the "main class".
    Should I specify main class when jar the files or in jnlp file?Either way should work, but I prefer in the JNLP file, to avoid the webstart client having to download any Jar(s) eagerly just to look for it.
    Lastly, when I upload my jnlp file to my web server, and try to access it through a web browser, it keeps saying that the web address is invalid. What address, what URL?
    ..Do I need any special permission from the web server to run jnlp file?No. All that is required is that it is accessible, and returns the correct content-type for .jnlp files.
    Thank you and have a wonderful dayIt's bright sunshine, clear skies and a lovely(1) 28 deg. C here, so not going too bad so far. ;)
    (1) Lovely if you are not working in the sun.
    Note that I also offer JaNeLA for comprehensive(2) checking of JNLP launches. Someone at your level of experience with JWS should definitely check it out.
    (2) JaNeLA's checks include validity of JNLP, content-type, resource availability..

  • Why do we need static for main() .........?

    Why do we need static for main method
    class Sample
    public static void main(String args[])
    System.out.println("HI EVERYONE");
    }

    The Java virtual machine is another term for the Java interpreter, which is the code that ultimately runs Java programs by interpreting the intermediate byte-code format of the Java programming language. The Java interpreter actually comes in two popular forms: the interpreter itself (called java) that runs programs via the command line or a file manager, and the interpreter that is built into many popular Web browsers such as Netscape, HotJava, and the appletviewer that comes with the Java Developer's Kit. Both of these forms are simply implementations of the Java virtual machine, and we'll refer to the Java virtual machine when our discussion applies to both. When we use the term java interpreter, we're talking specifically about the command line, standalone version of the virtual machine; when we use the term Java-enabled browser (or, more simply, browser), we're talking specifically about the virtual machine built into these Web browsers.
    excerpts Orelly "Java Threads" Chapter 1. (If you don't believe me). Did i do any fundamental wrong by saying interpreter ? Is that a Sin ?
    That is why i told concentrate on what answer I gave regarding the question. I am not going to argue any more. If you don't like my comments then I am Sorry :(

  • Standard/common handling void main(String argv[])

    i would like to have a parent class to handle the void main(String argv[]), but I can't instantiate my child class because I dun know it's name.
    any way to get that? or any alternative way to handle the void main(String argv[]) in common? million thanks.
    eg:
    public abstract class parent {
    public static void main(String argv[]){
    // i need to know which child is been run by java childclass
    // so that I can instantiate a new object and call the run method
    public abstract void run();
    public class child1 extends parent{
    public void run(){}
    public class child2 extends parent{
    public void run(){}
    }

    Class.forName(name).newInstance();
    provided I know name=what, right?
    how do I know ppl calling using
    java child1?
    or
    java child2?
    both will go use same
    public static void main(String argv[])
    in parent class.

  • Void mains

    Please help, I have just about had enough of this code for my lifetime.
    I am trying to get a timer running in the background that fires an event every minute.
    I had the code:
    public class Apl
        public static void main(String argv[])
            boolean gui = true;
            int portNum = 110;
            //server object
         POP3Server server;
            //user mailset
            Set mailSet = new HashSet();
            .  //does some stuff
    }So i try and modify it to do this
    e.g
    public class Apl
        public static void main(String argv[])
            boolean gui = true;
            int portNum = 110;
            //server object
         POP3Server server;
            //user mailset
            Set mailSet = new HashSet();
            .  //does some stuff
            TimerTask fetchMail  = new FetchMail();
            Timer timer = new Timer();
            timer.scheduleAtFixedRate(fetchMail, 1, 10000);
        public class FetchMail()
            System.out.println("HI");
    }In the hope it would print HI every 10 seconds. But no.
    Any ideas? Thanks

    Still having problems with this timer. I have had a rethink about what I want to do with it and am still having problems.
    private String makeMailDrop()
            String users = "";
            String thisLine;
            //DOES SOME STUFF HEREThen from another class
    public POP3Server(int port, POP3ServerFrame frame, Set mailSet)
             //vars
              this.port = port;
              this.frame = frame;
              this.mailSet = mailSet;
              gui=true;
                    uidlArr = new String[100];
                    counter = 1;
              //timer
              //makeTimer();
              output("Initializing..this may take a while..\n");
                    output("Welcome To Highway42 POP3 Server. \n\n");
                    makeMailDrop();
                    TimerTask loopMD = makeMailDrop();
                    Timer timer = new Timer();
                    timer.scheduleAtFixedRate(loopMD, 1, 10000);The problem being that the types are different, loopMD is a TimerTask and I am trying to assign it to a methiod that returns a string.
    so I tried TimerTask loopMD = makeMailDrop();and then it says it cant find makeMailDrop().
    How would I implement this so on the timer it runs makeMailDrop()
    Thanks

  • Neccessity of Public Static.

    My Warm Hello to Everyone Out there,
    I am absolutely New to Java. Absolutely. I am astonished by the pure beautiful advances made to the paradigm of C++, that created this enormous Programming language.
    Well I understand for the Most common example: "Example.java" Program that one may find in most of the books, as the starting program for the Life in Java...
    class Example{
        public static void main(string args[]){
            // body of main
    }In Which "Example". can this main() be anything else: private or protected?
    If no Why not?
    :: DreamyDinesh ::

    It seems that Java's Initial Versions might have been doing something else. It looks as if either, this
    method of sandwitching the main() inside a Class (whose nomenclature, is not 2 b ignored) was followed
    out of experience or it was well planned then, brought into action.It was ever thus. The JLS (Java Language Specification) has always specififed that a program's main
    is to be public and static, but some earlier versions of Sun's JVM didn't check for that public modifier,
    so one could thrill to having their private mains executed. The current JVMs do check for this.

  • Void main

    Hi,
    Could you please let me know what is wrong with this line please:
    Employee test= new Emp_FT(getId,getFirstName,getLastName,getEmployeeAge,getFullTime);
              public static void main(String args[])  
                         Employee test= new Emp_FT(getId,getFirstName,getLastName,getEmployeeAge,getFullTime);                 
         class Emp_FT extends Employee{
             private String fulltime;
            public Emp_FT( int id, String firstName, String lastName, int employee_age, String address, String ft )
                      super( id, firstName, lastName, employee_age, address);
                        this.fulltime = ft;
                    }Thanks
    Andonny

        public ArrayList parseFile(File input)
            String buffer = null;
            ArrayList data = new ArrayList();
            try
                FileReader fileIn = new FileReader(input);
                BufferedReader bufferIn = new BufferedReader(fileIn);
                buffer = bufferIn.readLine();
                while (buffer != null)
                        //write code here depending on how you arrange your file
                        //store values for name and id in local variables then create
                        //a new employee, if it is a fulltime employee then
                        Emp_FT emp = new Emp_FT(id, first, last, ssn, etc);
                        //or you could create an empoyee first then add the info
                        Emp_FT emp = new Emp_FT();
                        emp.setId(something);
                        emp.setFirstName(something);
                        //then add this employee to your list before proceeding
                        data.add(emp);                    
                    buffer = bufferIn.readLine();
                bufferIn.close();
            catch (IOException e)
                e.printStackTrace();
            return data;
        }

  • Default access specifiers for void main()

    I m having one problem that if i make void main(String a[])
    syntax like private static void main(String args[]) and run using jdk1.4 it will run. So my question is that why this is possible still i making main() private. If i run it in jdk1.5.0 then it give error main is not public so what was the problem with the jdk1.4?

    Congratulations on your first post after almost 2
    years. ?The most impressive thing is that he remembered his
    password ...I posted by first message in 2004, I only used this account to read the bugdatabase and vote on bugs prior to that. So I don't see anything strange in having an account, and not using the forums.
    Kaj
    Ps. But I'm also impressed by the fact that he remembered the password, I had an account which I created in -97, but I forgot the password to that account :(

  • Static private void main(String[]) works (?!)

    Did anyone knew that?
    try yourself!!
    public class Foo {
    static private void main (String[] bla) {
       //anything
    }there's even a bug!! And Sun choose not fix it:
    http://developer.java.sun.com/developer/bugParade/bugs/4252539.html
    I'd like to hear what you folks think about this...
    IMO: fuc* encapsulation!

    No, I haven't done the certification exam and I have no plans to. But the answer to that question isstatic public void main (String[] bla)and the fact that other versions happen to work doesn't matter either theoretically or practically. Bugs that appear in certain implementations of Java shouldn't matter.

Maybe you are looking for

  • Configuring log location for Adobe Document Services specific log

    Hi All, Interesting one for you. I am currently helping to resolve a PDF rendering issue which is intermittent. I have sent the default trace logs to SAP, however, there is an additional adobe specific log which should be written to /usr/sap/<SID>/SY

  • Problem installing Adobe CS4

    Hi, I am trying to install Adobe CS4 however when i press on the setup, the setups starts to inspect the system to check if it meets the minimum requirements. When this is ready, I get a larger window (as if setup is going to begin) and soon after a

  • Deploying internal and external wireless users

    what i have npw AP1232AG, WLSM and SUP720. i,ve implemented wlan for our internal users, via fast secure roaming. Now i want to setup the connection for external users. i have a seperate internet connection for external users . what is the best metho

  • Logical export backup

    LQ = > I exported hr schema with three different option of keyword CONTENT = ALL, CONTENT = METADATA_ONLY AND CONTENT = NONE 1.with keyword CONTENTS= ALL the size of dmp file was 416KB 2. with keyword CONTENTS=DATA_ONLY I got size = 216 3.Last with k

  • I have forgotten my password

    I have forgotten my password code, how can I open my phone? Going crazy