1 Attachment(s)
Converting a Java App to an Applet(with no GUI)
I have a working Java app that can find the most recently created file in a folder. My end goal is to have that app on a web page so when a user opens the web page the page will cause the most recent file in a folder to open. I've read some tutorials from oracle on creating simple applets, but everything I've come across involves making a GUI that my page will not need.
Currently, when I open the html page in firefox it loads all the html except for the applet. It gives no error messages, it just doesn't do anything. I think it's because it isn't recognizing my java app as an applet, so I think I may need to do more to convert my code to an applet. I added "extends Applet" to my java class name, and I looked into adding an init method, but that seems more geared towards those who want GUI's.
The java app is attached in case that may help. As far as the HTML goes, I embedded the applet as <applet code="FirstApplet" width='300' height='300'> and it is located in the same folder as the java app.
Re: Converting a Java App to an Applet(with no GUI)
I'm not sure, but I think it should be <applet code="FirstApplet.class" width='300' height='300'>, not
<applet code="FirstApplet" width='300' height='300'>.
I'm not very good with Applets but that is just a tips.
Re: Converting a Java App to an Applet(with no GUI)
No, you shouldn't have the .class extension. Check out the applet tutorial: Deploying With the Applet Tag (The Java™ Tutorials > Deployment > Java Applets)
We're going to need more information. Take a look at your Java Console for any errors or messages. You might have to turn the Java Console on, it might be off by default.
Re: Converting a Java App to an Applet(with no GUI)
Quote:
Originally Posted by
KevinWorkman
When I run the program through Eclipse as an application, it works perfectly and prints nothing to the Java console. When I run through Eclipse as an Applet, it opens the Applet Viewer: FirstApplet.class, and it says Applet started at the bottom of the viewer. But, it does not open the most recent file(or any file for that matter).
If I locate the html page that links to the applet and open it through my Mac, it reads all the HTML just fine except the applet, the applet is not launched.
I checked the Java console and it is on, and I also tried changing the named to FirstApplet.class with no luck. Please let me know if there is any further info I can provide.
Re: Converting a Java App to an Applet(with no GUI)
Then it sounds like some debugging is in your near future. You're going to have to step through this with a debugger, or at the very least add some print statements, to figure out what's going on.
Recommended reading: http://www.javaprogrammingforums.com...t-println.html