Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Java App To Web App
snutz411
post Mar 1 2006, 09:15 PM
Post #1


Advanced Member
Group Icon

Group: Members
Posts: 105
Joined: 22-December 05
Member No.: 10,229



I have this Java Application that is already coded which interacts with a database. Is there any way that would be easy enough to launch this application via a local intranet? It is not in any Applet package, but I do have the JARs. Can this be done without too much effort?
Go to the top of the page
 
+Quote Post
xboxrulz
post Mar 2 2006, 03:00 AM
Post #2


Colonel Panic
Group Icon

Group: [MODERATOR]
Posts: 2,881
Joined: 25-March 05
From: Toronto, Ontario, Canada
Member No.: 3,233
myCENTs:22.53



just make it a Java applet

CODE

public class FirstApplet extends Applet implements ActionListener {


where FirstApplet is the classname.

xboxrulz
Go to the top of the page
 
+Quote Post
viterbi209
post Mar 12 2006, 12:38 PM
Post #3


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 8
Joined: 12-March 06
Member No.: 11,920
myCENTs:28.63



Just like xboxrulz says, make it into an applet and the only other thing you would probably have to change would be the initial entry point into your code from:

CODE

public static void main(String args[])


to:
CODE

public void init()


also the class you need to import would be java.applet.Applet.

An alteranative would be to use java's swing components and for this you would import javax.swing.* and extend JApplet instead of Applet. The initial entry point into your code is still the same. So the code would look like this:

CODE

import javax.swing.*; // for JApplet and swing components
import java.awt.event.*; // for ActionListener

public class FirstApplet extends JApplet implements ActionListener
{
     ...
     public void init()
     {
          ... your code here
     }
}

Go to the top of the page
 
+Quote Post
snutz411
post Mar 13 2006, 02:10 AM
Post #4


Advanced Member
Group Icon

Group: Members
Posts: 105
Joined: 22-December 05
Member No.: 10,229



Thanks for the suggestions. I still have some tweaks to figure out in my program, then I'll start trying to turn it into a Web App. The thing is I only have a couple more weeks left at my job because its just an internship. So either it turns into a Web App or I'll just throw an executable on the intranet site.

I'd only have to fool around with the main file because its only a one liner which calls another class which does all the work.
Go to the top of the page
 
+Quote Post
uapconsole
post Mar 17 2006, 02:01 AM
Post #5


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 10-February 06
Member No.: 11,194



Perhaps this is stating the obvious: have you considered Java Networking Launching Protocol or JNLP. However, it is now commonly referred to as Java Web Start. The protocol instructions are simply XML files.

Good luck, follow this referrence: http://en.wikipedia.org/wiki/JNLP

- Demirelli
Go to the top of the page
 
+Quote Post
snutz411
post Mar 20 2006, 07:23 PM
Post #6


Advanced Member
Group Icon

Group: Members
Posts: 105
Joined: 22-December 05
Member No.: 10,229



Here's what my Main.java file looks like right now. It used to be just a one liner that called another class which did all the work. When I launch this through my web browser I'm getting an NoClassDef Error.

Also if I am creating an Applet using Eclipse as my IDE can I still compile it and launch the program from there as if it were a normal application?

CODE

import javax.swing.*; // for JApplet and swing components
import java.awt.event.*; // for ActionListener

public class Main extends JApplet implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        init();
    }

    public void init() {

        // Launch Tracking_GUI
        Tracking_GUI window = new Tracking_GUI();
        window.show();

    }

}



This post has been edited by snutz411: Mar 20 2006, 07:29 PM
Go to the top of the page
 
+Quote Post
snutz411
post Mar 20 2006, 07:51 PM
Post #7


Advanced Member
Group Icon

Group: Members
Posts: 105
Joined: 22-December 05
Member No.: 10,229



QUOTE(uapconsole @ Mar 16 2006, 09:01 PM) *

Perhaps this is stating the obvious: have you considered Java Networking Launching Protocol or JNLP. However, it is now commonly referred to as Java Web Start. The protocol instructions are simply XML files.

Good luck, follow this referrence: http://en.wikipedia.org/wiki/JNLP

- Demirelli



That's an option, but I would also have to make sure each computer has Java Web Start installed on it which is separate from the basic Java Runtime Environment.
Go to the top of the page
 
+Quote Post
BitShift
post May 8 2006, 10:38 PM
Post #8


Advanced Member
Group Icon

Group: Members
Posts: 153
Joined: 8-May 06
From: Houston, TX
Member No.: 13,291



Use Java Web Start

Has much better functionality then Applets.

It can automatically upgrade client JRE.

www.snakegame.i8.com

Thats for my snake game, the second link uses Java Web Start. Take a look at the JNLP format it uses, you can pretty much copy and paste.

Just open the .jnlp file in notepad.

It has an extremely slow launch process though, but its a Java app so it will be slow anyways.
Go to the top of the page
 
+Quote Post
evought
post May 8 2006, 11:41 PM
Post #9


Premium Member
Group Icon

Group: Members
Posts: 200
Joined: 3-October 05
From: Missouri
Member No.: 8,888
myCENTs:71.12



QUOTE(snutz411 @ Mar 12 2006, 09:10 PM) *

Thanks for the suggestions. I still have some tweaks to figure out in my program, then I'll start trying to turn it into a Web App. The thing is I only have a couple more weeks left at my job because its just an internship. So either it turns into a Web App or I'll just throw an executable on the intranet site.

I'd only have to fool around with the main file because its only a one liner which calls another class which does all the work.


That's the best case to work with. It is really easy then to leave the Main file intact and add an Applet class to the jar. The jar will work as either an applet or standalone depneding on how it is called. The Applet class file, like your main file, will contain very little.

Hopefully, your current Main file creates a toplevel frame and passes it to the class which does all of the work. In that case, you can create your applet and pass the Applet's Frame in instead. If not (if the inernal class creates a top-level frame), then it will take some more work to fix. At that point, post some snippets and I am sure people will help you out.
Go to the top of the page
 
+Quote Post
evought
post May 9 2006, 12:14 AM
Post #10


Premium Member
Group Icon

Group: Members
Posts: 200
Joined: 3-October 05
From: Missouri
Member No.: 8,888
myCENTs:71.12



QUOTE(snutz411 @ Mar 20 2006, 02:23 PM) *

<snip>
CODE

import javax.swing.*; // for JApplet and swing components
import java.awt.event.*; // for ActionListener

public class Main extends JApplet implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        init();
    }

    public void init() {

        // Launch Tracking_GUI
        Tracking_GUI window = new Tracking_GUI();
        window.show();

    }

}




OK, here is what I was mentioning with Frames and such. Here, you create a separate window from your applet. This is often considered poor form (people hate popups). It is often better to display your GUI within the Applet. JApplet has a getContentPane() method which returns a Container, You can modify Tracking_GUI to provide a new constructor which takes a Container as an argument. Everything in the Tracking_GUI gets packed into that Container. Your Tracking_GUI() constructor just creates a new Window and then passes *that* Container to the method which creates the widgets. Make sense?

CODE

public Tracking_GUI(Container c)
{
   Create_GUI(c);
}

public Tracking_GUI()
{
  my_frame = new JFrame("Tracking GUI");
  Create_GUI(my_frame.getContentPane());
}

public void Create_GUI(Container c)
{
  my_container = c;

  // Create widgets and add them to my_container
  JLable l = new JLabel ("foo");
  my_container.add (l);

  // etc.
}


Anyway, this is the kind of thing I have doen in the past. It makes it possible to run the same code as a standalone app, an applet, or even embedded in another application without a lot of fuss and bother.

Your Applet calls Tracker_GUI(getContentPane()) and your main calls TrackerGUI().

If this does not make any sense at all, I am probably over-tired and will try again later.
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. java.lang.NullPointException(4)
  2. Using system date in java... How?(5)
  3. Java Unlimited(14)
  4. Array Sorting(21)
  5. What Are The Advantages Of Java Vs C++?(15)
  6. Need Help: Find Lowest Character Using Java(7)
  7. Download Java Ebooks(15)
  8. Java By Example(8)
  9. Video Streaming In Web Browser Through Java Or Jsp(1)
  10. Looking For A Java IDE(25)
  11. On Why Java Is 'c'ooler!(10)
  12. Other Sound Format Support(3)
  13. Java Phone Book(2)
  14. How To Create Exe File In Java?(13)
  15. How Do I Test A Java Aplication(11)
  1. Need To Modify Xml Attribute Using Java(4)
  2. Bluetooth And Java(5)
  3. Java Sdk Vs. Java Jdk?(2)
  4. Graphcal User Interfaces In Java(4)
  5. Java Db Help Pls(2)
  6. Loading 3d Models In Java?(2)
  7. Java Applet Loading Error(5)
  8. Setting Up Java Correctly(8)
  9. Java Java.security.accesscontrolexception(6)
  10. Simple Java Question(3)
  11. Java And Sql: Data Mismatch(6)
  12. Java Memory Leak?(2)
  13. Java Mouse Movement.(2)


 



- Lo-Fi Version Time is now: 4th December 2008 - 11:13 PM