Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8169949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:00:47+00:00 2026-06-06T21:00:47+00:00

I have a working Java app that can find the most recently created file

  • 0

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 below in case that may help. As far as the HTML goes, I embedded the applet as applet code=”FirstApplet” width=’300′ height=’300′ (with proper opening and closing tags) and it is located in the same folder as the java app.

import java.applet.Applet;
import java.io.File;
import java.io.IOException;

@SuppressWarnings("serial")
public class FirstApplet extends Applet{
    public static File[] getPath(String folderPath){

        File directory = new File(folderPath);
        File[] myarray;
        myarray=directory.listFiles();
        return myarray;
    }
    public static String getMostCurr(File[] fileArray){
        File mostCurrent = null;
        for (int i = 0; i < fileArray.length; i++) {
            if ((mostCurrent==null)||
            (fileArray[i].lastModified()> mostCurrent.lastModified())) 
        {
            mostCurrent = fileArray[i]; 
        }                   }

        //System.out.println(mostCurrent.toString());       
        return mostCurrent.toString();
    }

    public static void main(String[] args) throws IOException{
        //opens file on MACINTOSH
        Runtime.getRuntime().exec(new String[]{"/usr/bin/open", 
                getMostCurr(getPath("/Users/guest/Desktop/lectures/testFileReader"))});
    }
}   

EDIT**: Here is the HTML page as requested.

<html>
<head>
<title>My First Java Applet </title>
</head>
<body>
Here's my first java applet:  <br> <br>
<applet code ='FirstApplet.class' width='300' height='300'>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:00:48+00:00Added an answer on June 6, 2026 at 9:00 pm

    It is HTML just for convenience.

    Developing, debugging and deploying applets (even to one PC) is not convenient or easy. Take that from me, I have vast experience with applets.

    It’s only going to be run on my manager’s computer who has all the necessary files.

    For one machine I’d use a standard app. with a main(), possibly launched from a shell script (e.g. .sh for OS X). Instead of the manager ‘clicking a link’ that browses to a page that automatically opens a file, they ‘run (double click?) the script’ that does the same thing. In Windows, you might have even linked directly from the HTML to a .bat file, but I doubt Apple would want to open that security hole.

    Also look to use Desktop.open(File) or Desktop.edit(File) instead of Runtime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working in a Web App with Java and JSF. I have a simple
I have been working on a Java game and I recently wanted to see
I have created a couple of java working sets for a project in my
I have been working on Eclipse recently. I am fairly new to java programming,
I have a Graphics object of JPanel and that is working fine: import java.awt.Color;
i have a java game app that uses sockets to communicate with each other.
All, I'm working on a java webapp that we deploy in the Resin web
I have been working on a simple Java app. I had it compiling and
I work on a Java web based app that uses both Jackrabbit and Hibernate
I'm working with a legacy Java app that's pulling data from Oracle. One of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.