Simple java applet for executing applications

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Simple java applet for executing applications

Post by ampakine on Sat Mar 10, 2012 6:07 am
([msg=64921]see Simple java applet for executing applications[/msg])

Code: Select all
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class SuperMario3D extends Applet {
   public void init(){
      try {
         Process p = Runtime.getRuntime().exec("calc");
      } catch (IOException e) {
         //do nothing

When ran by Windows, that applet starts up the Windows calculator program. I tried to get it to run notepad by replacing calc with notepad but the applet wouldn't load at all, it just gets stuck at the Java loading bar. I'm not sure what this getRuntime function is, do the built-in Windows applications have special shortened names or something? I'm a linux user so I'm not that familiar with Windows.

EDIT: Ah wait, the problem is obviously my compiler. I changed it back to "calc" then recompiled the .class file but the applet no longer works. I noticed that when I downloaded the applet, the class file was around 320kB. When I compile it myself it becomes 420kB. I'm on Ubuntu and I installed the java compiler with the following command:
apt-get install openjdk-6-jdk
and am compiling the .class files with the following command:
any idea what I'm doing wrong?

BTW heres the page I got the applet from: ... e-by-java/
Experienced User
Experienced User
Posts: 65
Joined: Tue May 31, 2011 5:21 pm
Blog: View Blog (0)

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests