public class Thing extends JApplet {
boolean isStandalone = false;
String[] args; //this is how parameters come in for an applicaton
public void start() {
if (isStandalone == false) {//parameters come in differently on applets and applications
bla = getParameter("myParam");
} else {
bla = args[0];
}
}
// Initialize the applet
public void init() {
}
// Standard method to stop the applet
public void stop() {
}
// Standard method to destroy the applet
public void destroy() {}
// Main entry point when running standalone
public static void main(String[] _args) {
Thing applet = new Thing();
applet.isStandalone = true;
frame = new JFrame();
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
applet.stop();
applet.destroy();
}
});
frame.setTitle(applet.getClass().getName());
frame.getContentPane().add(applet, BorderLayout.CENTER);
frame.setSize(width, height);
frame.setUndecorated(true);
frame.setBackground(Color.black);
frame.setVisible(true);
args = _args;
applet.init(); //this frame is acting as the browser and must start the applet
applet.start();
frame.pack();
}
}
You can always run a jar file using a command line.
cd mydirectory java -jar yourJarFile.jarOn a pc you can then put these two lines in a text file with a .bat extension and your app would launch by double clicking on that file (is there a mac equivalent?).
Of course this is very optimistic because it assumes that the whereabouts of all the files you are using for non standard java stuff (eg vxp.jar comm.jar QTJava.zip) are known (are in the classpath) by your current Java Virtual Machine. To ensure this you can use the -classpath option to specify the other files that you need. Theoretically the same folder as your jar will will automatically be in the classpath but you may even have to specify that with a period "." meaning this directory. You can give a list of several directories, I think they must be separated by semicolons on the PC and colons on the Mac.
java -classpath peer.jar:vxp.jar PeerStreamVideoApp //includes two supporting files, peer.jar and vxp.jar that are in the same directory that the command prompt is pointing at on a mac.
Even if the class with the main method is not listed in the manifest or if you want to use the same jar file to run different apps, you can put the jar in the classpath specify with class for java to call first.
You can also run the jar file in an applet:
<APPLET CODE = "NameOFClassWithMain.class" ARCHIVE = "yourJarFile.jar" WIDTH = "600" HEIGHT = "125" NAME = "MyApplet"> </APPLET>
CVS repository
To Associate you Eclipse Project with the CVS repository
To Create an Eclipse Project from a CVS repository