Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Converting a Java App to an Applet(with no GUI)

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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.
    Attached Files Attached Files


  2. #2
    Member
    Join Date
    Jun 2012
    Location
    Uppsala, Sweden
    Posts
    36
    Thanks
    10
    Thanked 1 Time in 1 Post

    Default 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.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Converting a Java App to an Applet(with no GUI)

    Quote Originally Posted by KevinWorkman View Post
    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.
    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.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. The Following User Says Thank You to KevinWorkman For This Useful Post:

    davidvee (July 2nd, 2012)

Similar Threads

  1. [SOLVED] Java applet
    By ikocijan in forum What's Wrong With My Code?
    Replies: 11
    Last Post: July 3rd, 2012, 02:54 AM
  2. Replies: 29
    Last Post: May 18th, 2012, 02:16 PM
  3. Converting Java Code to work with Android
    By Farmer in forum Android Development
    Replies: 2
    Last Post: May 12th, 2012, 09:16 AM
  4. Java Applet
    By Ludicrous in forum Java Applets
    Replies: 7
    Last Post: March 31st, 2012, 02:40 PM
  5. Need help converting Pseudocode to java
    By firebyrd in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 5th, 2011, 05:28 AM

Tags for this Thread