0

How do I run a java class as an applet in Eclipse, I don't want to run the applet in a browser.

I just want to run it in Eclipse with AppletViewer. I have a .class file but it won't run.

0m3r
  • 12,286
  • 15
  • 35
  • 71
Jon
  • 11
  • 1
  • `I have a .class file but it won't run.` -- How are you trying to run it? What error do you get when you try to run it? – azurefrog Jun 26 '15 at 15:37
  • I right click on the class file, go to "Run As", and there is no option to run it as an applet or application. If I hit the green arrow to run, nothing happens either. – Jon Jun 26 '15 at 15:46

1 Answers1

0

In eclipse you shouldn't try to interact directly with the generated files (such as .class files). There's a reason that it hides them from you by default in the most views.

Instead find the .java file which contains the class which extends Applet and go into its "Run As" menu. You should have the option to run it as a "Java Applet".

azurefrog
  • 10,785
  • 7
  • 42
  • 56
  • Oh okay, so there is no way to run just a class file (even on something other than Eclipse)? I don't have the java file. – Jon Jun 26 '15 at 17:04
  • Well, I suppose you can pull the .class file in as a resource (see [this question](http://stackoverflow.com/questions/661110/how-do-i-include-class-files-in-my-project-in-eclipse-java/661143#661143) and then write your own class which uses it and run *that*. Keep in mind that eclipse is a compiler, it really expects you to have the source code, so things are going to be much more convoluted when you don't. – azurefrog Jun 26 '15 at 17:15