Simple function

Status
Nicht offen für weitere Antworten.

Sorku

Mitglied
Hi, sorry for speaking english, my german isn't very good :wink:

I'm not 100% sure if it's possible, but is possible to create a .class file (that can execute a .jar file) that can be opened in a webbrowser?

Example:
Code:
<APPLET code="jarload.class" width="200" height="200"></APPLET>

What I'm trying to create is a printscreen button on a homepage in the webbrowser.
I'm currently developing a php based game client for a webbased java game if anyone is wondering. :)

I hope anyone speaks english here :roll: :D
 

Wildcard

Top Contributor
Yes, that's possible, but the applet has to be signed to do stuff like that.
The question is why you need the jar at all?
A signed Applet can do everything a jar can do.
 

Sorku

Mitglied
The reason is pretty simple - I don't know any java at all so it would be too complicated. :(

I found a jar that works just the way I want, so it would be much easier...

The question is then, how do I create a simple button that executes a jar file?
 

Wildcard

Top Contributor
1. Unpack the jar and look in the manifest how the main class is called
2. Write a simple Class that invokes the main class of the other jar.
For example:
Code:
class MyButton extends JApplet implements ActionListener
{
      public void init()
      {
               JButton button = new JButton("Print Screen");
               add(button);
               button.addActionListener(this);
      }
      public void actionPerformed(ActionEvent e)
      {
          MainClassOfTheOtherJar.main(null);
      }
}
3. Compile it
4. Make a jar out of your Applet and sign it
5. put both of the jars on the server and add both of them to the html code.
 

Sorku

Mitglied
You lost me there :?

I'm using this jar file:
http://dev.kanngard.net/dev/home.nsf/Permalinks/ID_20040702145456.html/$FILE/ScreenCapturer.jar

The main class is called "ScreenCapturer.class"
Is this code correct then? Don't I need to import any files?
Code:
class MyButton extends JApplet implements ActionListener 
{ 
      public void init() 
      { 
               JButton button = new JButton("Print Screen"); 
               add(button); 
               button.addActionListener(this); 
      } 
      public void actionPerformed(ActionEvent e) 
      { 
          ScreenCapturer.main(null); 
      } 
}

How do I add them both to the HTML code? :)
 
Status
Nicht offen für weitere Antworten.

Ähnliche Java Themen


Oben