Sorry if i sound foolish how to run an applet through a java application

I am into java from last one month ank keep on exploring it in the want to
recently i created a application cum applet in the same class like
applet is doing its own task and there is a main method in the code
that does entirly different task lets assume displaying *'s on the dos prompt the program is getting complied and belive it its running as desired
but the only problem that i m facing if i use appletviewer Myclass.java
only the appletprog is displayed
and if i run java Myclass than only dos task is done
may be it is sounding foolish for most of you but if i can get a way
which will help me in excecuting only one of it and both of them run succesfully
it tryied different ways to do it but was not succesful
please do not get irreated if its bizzered but if you really have a solution for it .i will appreciate it
thanking you

Yes you can run an Applet from an application. The magic bit is providing an AppletContext and AppletStub!
Here's how you start it:
        wpa = new WayPointsApplet(this);
        new AppletWrapper(wpa, 380, 320);Here's the class definition: (includes code for my application that can be ignored.
// Define a wrapper class for the applet
class AppletWrapper extends Frame implements AppletStub, AppletContext {
    Applet applet;
    // Constructor
    AppletWrapper(Applet a, int x, int y) { 
          applet = a; 
          setTitle(a.getClass().getName());
          setSize(x, y);
          Dimension ss = Toolkit.getDefaultToolkit().getScreenSize();
          setLocation((ss.width-x)/2, (ss.height-y)/2);
          add(a, "Center");
          a.setStub(this);
          // Trap window closing
          addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
                // Test if Write left undone before exiting???
                if(WayPoints.wpa != null) {
                  if(!WayPoints.wpa.okToExit())
                     return;           // Ignore
                applet.stop();
                applet.destroy();
                if(WayPoints.debug || WayPointDefs.plot_debug) {
                  SaveStdOutput.stop();
                System.exit(0);         // EXIT Program
          });  // end WindowListener
          a.init();
          show();
          a.start();
   } // end constructor
    // AppletStub methods
    public boolean   isActive() { return true; }
    public URL       getDocumentBase() { return null; }
    public URL       getCodeBase() {
        return WayPoints.currDir;
    public String    getParameter(String name) {
        if (name.equalsIgnoreCase("DEBUG")) {
            if (WayPoints.debug)
                return "YES";
            else
                return "NO";
        if(name.equals("PLOTDEBUG"))
            return (WayPointDefs.plot_debug ? "YES" : "NO");
        if (name.equalsIgnoreCase("SERVER"))
            return "NO";
        return "";
    public AppletContext getAppletContext() { return this; }
    public void      appletResize(int width, int height) {}
    // AppletContext methods
    public AudioClip getAudioClip(URL url) { return null; }
    public Image     getImage(URL url) { return null; }
    public Applet    getApplet(String name) { return null; }
    public Enumeration getApplets() { return null; }
    public void      showDocument(URL url) {}
    public void      showDocument(URL url, String target) {}
    public void      showStatus(String status) {}
} // end class AppletWrapper

Similar Messages

  • How to run a jar file using Java application.

    Hi all,
    I know that jar file can run using the following command, using the command prompt.
    java -jar jar-fileBut I don't know how to run that command through a Java code. Hope it's clear to you.
    So can you please explain how can I do it.
    Thanks,
    itsjava

    rayon.m wrote:
    The solution given by ropp appears to have nothing to do with what you asked about.Ok sir, I got the point.
    I've try a test as follows. But it doesn't give any output. Even not an exception.
            try {
                String[] temp = new String[]{"java", " -jar", " MainApp.jar"};
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec(temp);
                int exitVal = proc.waitFor();
                System.out.println("ExitValue: " + exitVal);
                System.out.println("Temp_Values");
            catch(InterruptedException ex) {
                System.out.println(ex.getMessage());
            catch (IOException ex) {
                System.out.println(ex.getMessage());
            }I've debug and see, but the exitValue is even not exist at run time. Can you tell me where I'm going wrong.

  • How to run an Applet using the JDK1.3.1 platform?

    I'm a beginner of Java Applet.
    I've type in the sample program provided in the text book, and compiled it using the jdk1.3.1 platform.
    Usually we run a java program using java [filename], right?
    How about running an applet file?
    What is appletviewer function?
    Thanks!

    I try to put it in a HTML page but it required me to download a Java Virtual Machine.
    I've been searching sources for that but stil cannot get.
    This is always what I get:
    [We're sorry, you cannot view this page because it requires the Microsoft Java Virtual Machine (MSJVM). Your machine does not have the MSJVM installed. For more information please visit www.microsoft.com/java.]
    I visit java.sun.com. On the right side of the page listed with the HOT DOWNLOADS.
    I click on the Java VM but still cannot get anything...
    Can u help me on that?
    I've been trying for 2 days already.
    Thanks!

  • HOw to run the Applet in dos mode

    how to run the applet in Command Prompt(DOS).
    I have save this in directory D/vijay/javap/A.java and my JDK is in C drive.
    Plz send me reply as soon as possible.
    My code is :-
    import java.applet.*;
    import java.awt.*;
    public class A extends Applet
    private int w, h;
    public void init( )
         w = 45;
         h = 50;
    public void paint(Graphics g)
         g.drawRect(w, h, 20, 80);
    }

    import java.applet.*;
    import java.awt.*;
    public class A extends Applet
    private int w, h;
    public void init( )
    w = 45;
    h = 50;
    public void paint(Graphics g)
    g.drawRect(w, h, 20, 80);
    <applet class="A" height="200" width="200" code="A.class">
    </applet>
    */And in command prompt
    javac A.java
    appletviewer A.java
    Message was edited by:
    passion_for_java

  • HOw to create a Batch file for java application and whats the use of this ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    First of all, you're OT.
    Second, you can find this everywhere in the net.
    If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
    javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
    Otherwise use:
    javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
    Don't specify the .class extension.
    Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
    The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
    This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
    Finally add dukes and give 'hem away.
    Bye.

  • How to create the exe files for java application

    How to create the exe file for java application?
    got any software to do that?
    Thanks

    In terms of converting java applications into exe files, there are 3 schools of thought:
    1) Instead of converting it to an exe, convert it to a jar file. Jar files are more portable than exe files because they can be double-clicked on any operating system. The caveat is that a Java interpreter must be installed on the target computer for the double-clicking to work.
    http://developer.java.sun.com/developer/Books/javaprogramming/JAR/
    2) Create an exe launcher that, when double-clicked, attempts to find a Java interpreter on the local computer and launches the Java application. The exe file is still double-clickable but whether your java application runs depends on whether a Java interpretor is installed on the target computer.
    http://www.sureshotsoftware.com/exej/
    http://www.objects.com.au/products/jstart/index.jsp
    http://www.duckware.com/products/javatools.html
    http://www.ucware.com/jexec/
    http://www.rolemaker.dk/nonRoleMaker/javalauncher/
    http://www.jelude.cjb.net/
    http://thor.prohosting.com/~dfolly/java/index.html
    3) Create an exe launcher that bundles a Java interpretor. Same as above but when the exe file is double-clicked, it searches for a Java interpreter and if one is not found, it installs one on the target computer. The caveat is that the exe file would have an overhead of 10 MB in size for the interpreter.
    http://www.excelsior-usa.com/jet.html (evaluation version available)
    4) Convert the Java application into a native exe file. The caveat is that if you use Swing for your GUI, it won't be converted. Also this option is still somewhat experimental.
    Can't think of any free options right now.

  • How to create a Batch file for java application  ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    [http://static.springsource.org/spring-batch/]
    Assuming you want to develop a batch application rather than actually just create a .bat file ..

  • How to deploy a POJO or a java application in oracle ESB?

    hi,
    I m beginner in oracle ESB.
    please someone tell me how to deploy a POJO or a java application in oracle ESB?
    thank you.
    Peter.

    The short answer is "you wouldn't"
    The long answer is that you would expose your Java Application or POJO as a Web Service then virtualise it through the ESB.
    If you're wanting to learn more about SOA, ESB and BPEL have you been to this site http://download.oracle.com/docs/cd/B31017_01/index.htm

  • How to send a mail through web dynpro application

    Hi
    How to send a mail through web dynpro application?
    Thanks

    Hi ,
      Please post some more details about your query .
    One way is to can use LinkToUrl UI element and in the reference property of the UI element , give it as mailto:mail addess
    Thanks.
    aditya.

  • How to assign the Thems into Webdynpro Java Application

    HI All,
                   I Downloaded the plugin for them editor and i add those plugins and i created the Them. Please any one can help me how to add that Them into Webdynpro java application.

    Hi ep bhargav,
    You can check this link.....
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ccb6bcf4-0401-0010-e3bc-ec0ef03e13d1
    Re: webdynpro theme editor
    Thanks.
    Venkat.

  • How to import the image by using java application

    1.how to import the image by using java APPLICATION and display it on the textarea that you have been created.
    2.how to store the image into the file.
    3. what class should i used?
    4. how to create an object to keep track the image in java application.
    * important : not java applet.
    plzzzzzzz.
    regards fenny

    follow the link:
    http://java.sun.com/docs/books/tutorial/2d/images/index.html

  • Can anybody tell me how to send/receive  the sms from java application

    Hi All,
    Can any body tell me, how to send/receive the sms from java application to mobile phones.
    I have installed the jsms engine and when i try to connect to the mobile device ,the jsms server is giving
    the following error.
    Cannot connect to GSM Device, error : -11

    Which jsms? Google finds several.
    Try the website where you downloaded it.

  • Can any body tell me, how to send/receive the sms from java application

    Hi All,
    Can any body tell me, how to send/receive the sms from java application to mobile phones.
    I have installed the jsms engine and when i try to connect to the mobile device ,the jsms server is giving
    the following error.
    Cannot connect to GSM Device, error : -11

    The best place to ask your question is at the JSMS website, forum or mailing list since this is no error that directly comes from a class belonging to the core Java classes.

  • How to run an applet(in a html file) in the server?

    I am using the jpedal Viewer inmy code, I embedded the applet code
    in a html file , it is running fine, but when I try to run the same Viewer applet in the Server it is throwing an error
    "java.lang.NoClassDefFoundError: org/jpedal/objects/acroforms/DefaultAcroRenderer
         at org.jpedal.PdfDecoder.startup(Unknown Source)
         at org.jpedal.PdfDecoder.<init>(Unknown Source)
         at pdfViewer.PdfApplet.init(PdfApplet.java:199)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)"
    What is the problem ?
    Please suggest solution for it?
    Its urgent

    I am trying to run the Applet in Tomcat server,
    Could you post the code where you invoke the Applet? It sounds like you're saying you're trying to run the Applet as part of your server-side code. The other interpretation is that you are simply accessing the Applet through the browser that happens to be on the machine being used as the server.
    Like I say, post the code that shows how you're trying to use the Applet "on the server".

  • How to run an applescript through terminal

    Hi Friends,
    I want to run an apple script by terminal. Any ideas how can we do it?
    I tried using the below code in terminal as
    osascript script_name.scpt.
    But, it returns an error.
    Thanks for your help!
    Regards,
    Abhishek

    Hi,
    I am sorry for not being explicit in my earlier post.I wanted to know basically what is the syntax of running an applescript through my terminal.
    Below is the errror message when I use the below syntax in terminal
    osascript script_name.scpt
    2012-10-30 11:34:43.667 osascript[2388:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
              /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
    osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
    2012-10-30 11:34:43.669 osascript[2388:903] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScript ingAdditions:  dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QX PScriptingAdditions, 262): no suitable image found.  Did find:
              /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPS criptingAdditions: mach-o, but wrong architecture
    osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
    script_name.scpt: execution error: No user interaction allowed. (-1713)
    Hope it helps!
    Thanks,
    Abhishek

Maybe you are looking for

  • The application was unable to start correctly (0xc0000142). Click OK to close the application. error: 0x6740090A-0x20003

    Hello, I have installed the app-v 5 client on a 2012 rd server. After publishing the application I'm getting the error "The application was unable to start correctly (0xc0000142). Click OK to close the application." The registry value NtfsDisable8dot

  • How to move Pictures Folder to a new location.

    I have 4 internal HD's and I would like to dedicate one to be my Pictures HD/Folder. Is it as simple as copying the folder to that drive? I hope so. I use Photoshop and Lightroom only. Just use IPhoto for desktop wall paper folder. Thanks!

  • Burn new DVD or copy existing DVD?

    For reasons too stupid, ignorant and boring to go into, I have so far been deleting the imovieproject files after I have burned to DVD, retaining the DVDproject files. I need to clear the 50 odd GB these take up. In case I need to make a copy of a DV

  • Non updated data in a cube

    Hi Friends, I have initialized a cube. in that there are 70 packages available. but the QM status has not changed into Green. while I see the details, only one package ( Package No. 38)   has yellow states. in that package, Transfer rules, Update rul

  • Download file servlet

    Hi, I have a servlet that downloads files. I was able to set the default download filename with the following code: response.setHeader("Content-Disposition", "attachment; filename="+downloadName); Is it posible to specify the default directory to sav