7 Replies - 763 Views - Last Post: 04 July 2012 - 11:23 AM

#1 davidvee  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 22
  • Joined: 26-June 12

Integrate Java Application with HTML page

Posted 26 June 2012 - 08:09 PM

I have created a java app that will discover all the files in a folder and tell me which one is the newest. How can I make a web page run the java app and display a link to the newest file on the web page?

Thanks,
David
Is This A Good Question/Topic? 0
  • +

Replies To: Integrate Java Application with HTML page

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2937
  • View blog
  • Posts: 7,690
  • Joined: 08-June 10

Re: Integrate Java Application with HTML page

Posted 26 June 2012 - 10:34 PM

isn’t client side Java done through Applets?
Was This Post Helpful? 1
  • +
  • -

#3 davidvee  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 22
  • Joined: 26-June 12

Re: Integrate Java Application with HTML page

Posted 27 June 2012 - 05:16 AM

View PostDormilich, on 26 June 2012 - 10:34 PM, said:

isn’t client side Java done through Applets?


Yes, but I'm pretty unfamiliar with Applets. Is there an easy way to convert an app to an applet? Or does it have to be done manually?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2937
  • View blog
  • Posts: 7,690
  • Joined: 08-June 10

Re: Integrate Java Application with HTML page

Posted 27 June 2012 - 06:11 AM

don’t know myself, but the guys in the Java forum should know.
Was This Post Helpful? 0
  • +
  • -

#5 denting5  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 84
  • Joined: 03-June 12

Re: Integrate Java Application with HTML page

Posted 27 June 2012 - 06:57 AM

Here is the basic stuff to set up an applet.
//  <applet code="Sketcher" width="300" height="300"></applet>
//  use: prompt>appletviewer Sketcher.java
import java.awt.*;
import javax.swing.*;
 
public class Sketcher extends JApplet {
 
    public static void main(String[] args) {
        JApplet applet = new Sketcher();
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(applet);
        f.setSize(300,200);
        f.setLocation(100,100);
        applet.init();
        f.setVisible(true);
    }
 
    public void init() {
        JMenuBar menuBar = new SketchFrame("").getJMenuBar();
        setJMenuBar(menuBar);
    }
}

Then you just have to embed that into the page.
Was This Post Helpful? 1
  • +
  • -

#6 davidvee  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 22
  • Joined: 26-June 12

Re: Integrate Java Application with HTML page

Posted 01 July 2012 - 11:55 AM

View Postdenting5, on 27 June 2012 - 06:57 AM, said:

Here is the basic stuff to set up an applet.
//  <applet code="Sketcher" width="300" height="300"></applet>
//  use: prompt>appletviewer Sketcher.java
import java.awt.*;
import javax.swing.*;
 
public class Sketcher extends JApplet {
 
    public static void main(String[] args) {
        JApplet applet = new Sketcher();
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(applet);
        f.setSize(300,200);
        f.setLocation(100,100);
        applet.init();
        f.setVisible(true);
    }
 
    public void init() {
        JMenuBar menuBar = new SketchFrame("").getJMenuBar();
        setJMenuBar(menuBar);
    }
}

Then you just have to embed that into the page.

Thank you for that. Since I do not need a GUI, I decided to just add "extends Applet" to my class name, but I have not had much success so far. Then I referenced the program from one of my html page as <applet code='FirstApplet.class'> </applet>. Opening the html page should cause my applet to start and open the most recent file in the directory I used, but nothing seems to be happening. Anything else I should try to get it to work?
Was This Post Helpful? 0
  • +
  • -

#7 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2707
  • View blog
  • Posts: 10,579
  • Joined: 15-July 08

Re: Integrate Java Application with HTML page

Posted 01 July 2012 - 12:20 PM

You can have an Applet and Application at the same time with this code snippet from pbl:
http://www.dreaminco...snippet4467.htm
Was This Post Helpful? 1
  • +
  • -

#8 davidvee  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 22
  • Joined: 26-June 12

Re: Integrate Java Application with HTML page

Posted 04 July 2012 - 11:23 AM

In case anyone in the future may want to know, I figured out the best way to approach this is to create a Java Web Start. Overall it seems pretty simple except the JNLP page that has to be set up. I decided against using an applet because it's tricky to allow it access to a user's local file directories. Thank you guys for the help.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1