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..

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();

  • 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 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

  • 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.

  • Reinitialization of static data by multiple applets

    Hi,
    I have a problem with initialization of shared static data by multiple applets. I have three applets running inside of different HTML frames in a multi-frame HTML framework. Applets are loaded as JAR files. In addition, every applet has one or two 3rd party JARs listed in the APPLET tag. Applets share the same codebase and run inside the same JVM.
    I use static data to perform the inter-applet communication. This is simply a static list of applet references that is being maintained in the base applet class (all applet classes are inherited from that class). The problem is that when applets get constructed, the static data in the base class sometimes gets reinitialized multiple times. As I understand, the static data should be initialized just once on initial load of the base applet class (applets have the same codebase).
    This problem seems to be caused by the race condition (applets initialize on different threads launched by the browser). Under some circumstances (I change the number and order of JARs, etc.) everything works fine. I can reproduce this problem on both Explorer 5.x and Netscape 4.7 (did not try others). I run applets using native browser's JVM.
    Has anybody had such problem before? Is it caused by the large number of JARs ? Is there any way to guarantee that static data will be initialized once in the multi-applet environment ?
    Thanks,
    hparfen

    Hi,
    Did you find something to solve your problem because I have exactly the same.
    Tony

  • Why is removeRange() static void?

    Hi.
    The subject line pretty much explains it. To me it seems that if the method was instead as easy to use as the other mutators, it would mean easier handling of the ArrayList?
    I will say, though, that I am very open to explenations, and do not at any time consider this is a critic opinion of the choice to make it static void. I do not have anything near the competance to make such a claim. I am just seeking enlightenment ;).
    Here is a link for the API for the class:
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html
    Thankyou.

    I will say, though, that I am very open to
    explenations, and do not at any time consider this is
    a critic opinion of the choice to make it static
    void. Well, they didn't. It's an instance method.

  • 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 Jarring - Class Not Found

    Hi,
    And again, java web start is one step ahead of me ;p
    (re the last post)
    I have simplified my requirements and have restricted my application to just one look and feel. That is in the original downloaded jar it came with (signed).
    My application has now gone through several versions, and each version has had several jar files containing different classes and things. I have never yet needed to specify a jar file in the manifest of another jar file to make it work.
    However, it cannot load the look and feels now. In the main class, I use:
    UIManager.setLookAndFeel("com.incors.plaf.kunststoff.KunststoffLookAndFeel");- where the look and feel is in a jar file pointed to in my classpath. Run locally, it works fine, but run over JNLP it throws a ClassNotFoundException.
    If I change it to:
    UIManager.setLookAndFeel(new com.incors.plaf.kunststoff.KunststoffLookAndFeel());Then the look and feel loads ok in both local and jnlp modes, but now it cannot find UI classes for things like JButtons when running over JNLP.
    Im using exactly the same jar file each time. Can anyone help?
    DS

    Got to stop doing this..
    Those of you having problems in this area take a look at these two links..
    http://developer.java.sun.com/developer/bugParade/bugs/4155617.html
    and
    http://forum.java.sun.com/thread.jsp?forum=38&thread=166873
    Its a botch method round it (and should have been fixed by now..?) but it basically entails providing a class loader gotten from a JComponent.
    Ive created a little class subclassing JApplet:
      private static class LFLoader extends JApplet
        public LFLoader() {}
        public void load()
          try
            UIManager.setLookAndFeel(new com.incors.plaf.kunststoff.KunststoffLookAndFeel());
            UIManager.getLookAndFeelDefaults().put( "ClassLoader", cl );
            aei.gui.components.JJSetup.setSimpleLFUsed(false);
          catch(Exception e)
          { System.out.println(e.getMessage()); e.printStackTrace(); }
      }You cant just call new Applet().getClass().getClassLoader() for some reason.
    The type of classloader displayed when the application starts..? sun.misc.Launcher$AppClassLoader if running locally, or com.sun.jnlp.JNLPClassLoader if over JNLP.
    My app now works but .. subclassing an applet to get it going .. eech!
    DS

  • Exeption from the invoked install() method?

    When I run my scr script I get this exception reported by the jcwde:
    Exeption from the invoked install() method:public static void javacard.framework.Applet.install(byte[],short,byte) throws javacard.framework.ISOException
    It happens when I try and create my applet. ANyone know what this means? My install method just pases everything to my applets constructor, which extracts the parameter dat from the byte[].
    Cheers,
    Niraj

    When I run my scr script I get this exception reported
    by the jcwde:
    Exeption from the invoked install() method:public
    static void
    javacard.framework.Applet.install(byte[],short,byte)
    throws javacard.framework.ISOExceptionJCWDE is not able to support the
    downloading of CAP files
    use cref instead
    see JKD Users Guide

  • Using a main in an Applet

    Hello, I have a question.
    How do you use a mian in an Applet.
    Eample, after an applet section is complete, I want it to go into Console use. Does anyone know how to combine the two? Thanks
    Note: So far, I got the program to go into the Console but It stops working when it asks for user input. There are no "String args[]" and that is what I hypothesis is the error

    import javax.swing.*;
    public class MyApplet extends JApplet {
         public void init() {
              //init stuff here
         public void start() {
              //start stuff here
         public static void main(String[] args) {
              JFrame f = new JFrame();
              JApplet a = new MyApplet();
              f.getContentPane().add(a);
              f.setSize(600, 400);
              f.setVisible(true);
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              a.init();
              a.start();
    }Excuse me, but is there a way to do this on Applet only instead of JApplet... I was told we need to use Applet only...

  • Problem in file association and main-class in JWS

    Hello , all
    I have a problem in JWS with file association and main-class. I have a java application that has two entry classes, one is appmain.class that is required to launch from web, and the other is player.class that is required to launch when user double-click the .abc extension file.
    In JWS 5.0+, there is a association element in JNLP syntax that can be used to make the file association with .abc extension. But how can I declare the main-class in JNLP file?
    If I declare the application-desc element as <application-desc main-class="player">, the player.class will be launched from web. But if I declare it as <application-desc main-class="appmain">, the .abc extension wil be associated to the appmain.class.
    Does anyone know how to solve this problem? Thank you for your kindly help.

    One way is to define a third main that refers
    to the other two, as appropriate. E.G. if the
    web based main does not include -open as
    its arguments, it is easy.class WebStartSpringboard {
      /** Call web based main unless args include -open. */
      public static void main(String[] args) {
        if (args[0].equals("-open") ) {
          OpenFileBasedClass.main(args);
        } else {
          WebBasedClass.main(args);
    }Other measures might be taken for a situation
    where the web based version does include a
    -open argument.

  • Blocking the applet and main threads ?

    The thread that runs the Applet callback methods like init() and start() is a thread named �applet-your.package.your.classname.class�.
    If I am doing a blocking method call, i.e. a method call that does not return immediately like doing I/O read on a socket connection, is it ok to do it on the thread mentioned above ? In other words, is it ok to hang/suspend/block the applet thread ?
    What about blocking the �main� thread that calls
    public static void main(String args[]) {�}
    Thanks.

    eminformatics, thanks for the reply.

Maybe you are looking for