Page 1 of 2 12 LastLast
Results 1 to 20 of 24
  1. #1
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default Re: Deploying web application from Java classes

    I have a legacy Java system that I am trying to get run on a web server. I have Tomcat installed and have added the class with main() into the folder but when I type in the localhost: command in the browser it says Java required. I made sure Java is enabled on web browser. Any ideas? Thanks a bunch.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    have added the class with main() into the folder
    when I type in the localhost: command in the browser
    Can you explain what your setup is?
    What code is on the server, what do you enter in the browser's location window?
    What machines do you have java installed on? Server vs local?

  3. #3
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    oh yes, thanks for the reply. I have a rather large Java standalone app developed and comiled through Eclipse. I am trying to run an html file that had been created through a web browser (index.html). I have Tomcat downloaded and installed but I am not sure how to implement that. Thanks for your response.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    I'm not sure where the parts for this are located. Are they all on the server except for the browser which is on the client machine.

    What do you type in the browser's location window?
    Does the browser read the first page from the server OK?
    Are there errors?
    Where/when do you expect the java application that is on the server to execute?
    How is the java application related to the html page you read with the browser.

    This sounds more like a server setup problem. Is there a forum for setting up the server you are using?

  5. #5
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Thanks, Norm, for your response!

    I type http://localhost18080/<myClassName.class> where 18080 is an abstract port number. I am running Tomcat as server, and pointed it to my jdk folder and everything. The only error I get is when I startup Tomcat I get UnsatisfiedLinkError (but that might be due to me running 32 bit .dll on my 64 bit windows 7) otherwise it is fine. I am basically trying to get a Java program that already exists to run via html. The code I was presented is this:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
    <title><!--#exec cgi="/GetMachineName.fn"--></title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <link rel="shortcut icon" href="/favicon.ico">
    </head>
    <body style="border-width:0px;margin:0px;padding:0px;" onResize="ResizeApplet();ResizeApplet();">
    <applet id="myApplet" style="border-width:0px;margin:0px;padding:0px;" archive="truenet_fx.jar, jai_core.jar, jai_codec.jar, PDFRenderer.jar" code="TrueNetFX.java" width="800" height="600" align="left" vspace="0" hspace="0">
    </applet>
    </body>
    <script language="JavaScript">
    var iMinAppletX = 800;
    var iMinAppletY = 600;

    function ResizeApplet()
    {
    //ResizeWindow();
    if(navigator.appName.indexOf("Opera") != -1)
    {
    x = document.body.clientWidth;
    y = document.body.clientHeight;
    }
    else
    {
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
    }
    if(x>=iMinAppletX)
    {
    document.getElementById("myApplet").width = x;
    }
    else
    {
    document.getElementById("myApplet").width = iMinAppletX;
    }
    if(y>=iMinAppletY)
    {
    document.getElementById("myApplet").height = y;
    }
    else
    {
    document.getElementById("myApplet").height = iMinAppletY;
    }
    }

    ResizeApplet();
    </script>
    </html>

    In the code I do see where it is archived some .jar files but not sure if those mean anything. I am wondering if using JSP is the way to go? Thanks for all you do by the way.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    I type http://localhost18080/<myClassName.class> where 18080 is an abstract port number.
    I assume that is what you are entering in the browser's location field. Is that correct?
    What you are doing is having the browser send an HTTP GET request to the server asking it to read the .class file and return it to you. Is that what you want to happen? The contents of a .class file shouldn't be much use when viewed in a browser.

    trying to get a Java program that already exists to run via html.
    Where are the .class files for the java program? Where do you what it to run?

    What is the name of the html file that you posted? Is it on the server? That is what you want the browser to GET from the server. The html has an <APPLET tag which will tell the browser to go back to the server to get the applet's class files.

  7. #7
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Hi Norm actually I made a mistake. That was supposed to be .jar file. I assume that when the HTML request picks up the .jar file it executes as a Java program? I am by the way what I call an "intermediate beginner" when it comes to Java. I can do great when I actually write my own programs but when put in someone else's development space I get confused. Thanks for your help!

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    I assume that when the HTML request picks up the .jar file
    HTML does not execute. It can't "pick up" anything. The browser is the executing code.

    You need to do some reading to see what the process is for a browser to read an html file with an <APPLET tag that has an archive= attribute. The browser will read the jar files as needed and then use the code= attribute to find the java class to call to start the APPLET (NOT an application).

  9. #9
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    I will do that Norm. To answer previous question my .class files are in c:\eclipese3\<my application> along with the html files . I set an index.html as the one that calls the applet. I will read up. Thanks again for your help!

  10. #10
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Hi Norm, I figured most of it out. Yes, the .jar archive points the html to the java executable, and then I write CODE = "MyClass.java" as the entry point. Now that was for my own test program (and again, that's where I excel at Java development I am trying to create an html file for the legacy program I am working on but Eclipse doesn't create a executable .jar file for me. What is also weird is that when I export it out to a .jar file, it doesn't allow me to select the executable class with the init() method. Any ideas on that one? Thanks SO much for your help, Norm!

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    when I export it out to a .jar file, it doesn't allow me to select the executable class with the init() method
    Not sure what you mean by "select". I don't know how your IDE works.

    I write CODE = "MyClass.java" as the entry point.
    This is probably wrong. With this code= attribute, the browser will look for the file: java.class in the package MyClass. Have you read the API doc for how to write an <APPLET tag?

    I am trying to create an html file for the legacy program
    If you are using the APPLET tag in html to execute a java program, the program must be a Java applet.
    The word "legacy" makes me think it is NOT an applet.

  12. #12
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Hi Norm, thanks for your help again. What it is is in the main class (MyApp()) I want to run as an applet. So I set the entry point for MyApp() because it has the main(). I exported from Eclipse all of the code from which I made a .jar file out of it, and it executes just fine on all of my machines. I created .html file where I set ARCHIVE = "MyApp.jar" and CODE = "MyApp.java" and the applet doesn't run. I get ExceptionInInitializerError in the console. I also made sure all files were located in my test directory. Where would I find the API doc for <APPLET> tags? If some of my questions seem silly, I'm what you would call a newbie. Thanks again for everything,

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    You still do not understand what I said about applets and applications. They are executed in completely different environments. You need to research how applets work.
    An application is executed by the java command on a command line.
    An applet is executed within a browser that is reading an html file with an Applet tag.

    Go to this site and search for applet:
    The Really Big Index

  14. #14
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Pretty sure it is an applet. The class name is public class myApp extends javax.swing.JApplet implements UncaughtExceptionHandler, StatusUpdate_Callback{}; Now, re: the fact that applets have to have init() to run, do you think the public static void main is getting in the way? Thanks for your help, and again I am a rookie!

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    The main() method would not be used in an applet and should not cause a problem unless there is code in it that needs to be executed and is not being executed because it is not called.

    If the class name is myApp, then the Applet tag's code= attribute should be code=myApp (if the class is NOT in a package).

  16. #16
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    I see norm. The interesting thing is that the main() method actually houses the line JApplet ja = new MyApp(boolean isApplet). MyApp(boolean isApplet) is one of the constructors. Then the applet is initialized in main() with the line ja.init(); that sounds normal. When I went into the class def. for MyApp(boolean isApplet) constructor it also has an init(). i am assuming the main() calls first, no?

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    As I said before, the main() method is NOT used in applets.
    Where is the author of the code? Did he/she provide any documentation for how to use it?

  18. #18
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Hey Norm , no the author is not around. The code is basically an amalgamation of 10 years of different programmers. No javadoc or any other documentation for that matter. I kind of got tossed into the shark tank on this one. Thanks for your input though!

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    Only advice I can think of is to find some simple applet code to play with and see what it takes to load it into a browser and execute it.

  20. #20
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    That's what is so funny though. I did create a simple MyAppletTest() class and compiled it, created a jar file for archive, and then composed a html file with the class in it (code = MyAppletTest.java. It works perfectly fine in browser.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 9
    Last Post: 01-17-2012, 08:31 AM
  2. Deploying a JSF Web Application to a Server
    By Nivedita in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 05-01-2011, 09:07 AM
  3. Replies: 3
    Last Post: 10-28-2010, 02:42 PM
  4. error deploying Enterprise application
    By mihael in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 01-30-2009, 10:46 AM
  5. Deploying a java application on an web or appp server.
    By CharanZ in forum Advanced Java
    Replies: 1
    Last Post: 10-29-2008, 10:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •