This discussion is archived
8 Replies Latest reply: Apr 10, 2013 9:56 AM by 920441 RSS

Execute Java file (jar) on client side

920441 Newbie
Currently Being Moderated
In my development, i am trying to execute a java executable file(jar) on client side. that jar file contains GUI mode or AWT controls application. i place a jar into PS home -> class directory. while i am calling that API class from the peoplecode , it throws an error message like

" Java Exception: java.awt.HeadlessException: during construction of com.guiffy.inside.GuiffyPanel. (2,768) TST_REC.OK_BTN.FieldChange PCPC:79 Statement:1
The constructor for the given class threw the noted Java exception. "

any one tell me a way to execute a java executable file on client side or on client browser.?

Edited by: sasi on Mar 4, 2013 3:53 PM
  • 1. Re: Execute Java file (jar) on client side
    HakanBiroglu Oracle ACE
    Currently Being Moderated
    If I understand you correctly you do not want the java to be executed on the application server but by the browser/client?
    To start with the main question, is the java code designed to run in a browser (applet)

    I would say use javascript
    or
    call the jar file/applet from an html area op a page
    http://docs.oracle.com/javase/tutorial/deployment/jar/run.html
  • 2. Re: Execute Java file (jar) on client side
    920441 Newbie
    Currently Being Moderated
    Thanks for your quick response.

    Actually, i need to compare two files using third party tool called Guiffy. They provide Guiffy.exe as well as Guiffy.jar. In Guiffy.jar class files contains awt controls and swing controls(JPanel,JFrame classes) to generate the GUI report. While i try to invoke their classes using java, it work fine and get the results. In other case, i placed jar file in %PSHOME%/class directory and run it on browser , i get the error message which i showed before question.

    I tried to use peoplesoft IScript to generate the dynamic HTML content(GUI content ) to load browser. Even though i am facing the same java exception. In your example shows that using javascript they are executing the jar file like a command line argument. But unfortunately this solutions is not fit for my requirement. Is there any other possible solution for my problem.?
  • 3. Re: Execute Java file (jar) on client side
    RCC Journeyer
    Currently Being Moderated
    You can't expect a GUI running on the application server via PeopleCode to be displayed on the client with this particular strategy. Try having it save the data directly to disk without displaying and then do something with that output. I think you need to read the instructions for your tool more. The Guiffy webpage makes it sound like you can do this with that tool.

    Command Line Interfaces:
    Guiffy includes several GUI and non-GUI command line interfaces for automation and integration with your environment. For further information, see the Command Line Interfaces in Guiffy's Help.

    -ah -autoh fn      Automatically Save the Difference as HTML and Exit
         For example: -ahC:\build\w3\About.html automatically saves the difference as HTML to the "C:\build\w3\About.html" file set

    Unfortunately, you didn't provide your requirements so we can only guess on a solution.
  • 4. Re: Execute Java file (jar) on client side
    920441 Newbie
    Currently Being Moderated
    Sorry Mr.RCC i forget to give you a clear information about my requirement,

    My requirement is, i have to compare two diffrent files using Guiffy compare tool and then display the compared result on client side in form of GUI mode within the browser itself. Guiffy GUI mode results displays the output in vertically. so we can easily see the difference between the two files. Using Guiffy.jar, its possible do it compare in java. If i am integrate with peoplecode it shows an error message while loading into browser. error message is,

    " Java Exception: java.lang.NoClassDefFoundError: com/guiffy/inside/GuiffyFanel: finding class com.guiffy.inside.GuiffyFanel (2,725) WEBLIB_GUIFFY.OK_BTN.FieldFormula Name:IScript_GuiffyCompare PCPC:263 Statement:3 "
  • 5. Re: Execute Java file (jar) on client side
    RCC Journeyer
    Currently Being Moderated
    Where are the files your trying to compare? What's wrong with the html file it creates, have you looked at that yet? Start simple just getting your compare to run/work before trying to get fancy and display it to the user.

    http://www.guiffy.com/help/GuiffyHelp/Inside.html
    The guiffy.inside package provides an API for building Guiffy inside Java applications --- or applets(trusted) --- or web application servlets.

    This may allow you to build your own applet from the guiffy API to accomplish what you want, but again, maybe you should be reading the guiffy documentation more to figure out how to accomplish what you want. I don't think I can help you further.
  • 6. Re: Execute Java file (jar) on client side
    jim.marion Pro
    Currently Being Moderated
    What I am about to say may be common knowledge, so please no offense if this seems too simple minded. I just want to make sure everyone is clear on a few facts:

    1. PeopleCode does not run in the browser. PeopleCode has absolutely no interaction with the client. PeopleCode can generate HTML, CSS, JavaScript, XML, JSON, images, etc, that can be rendered by the browser or browser plugins (flash, applets, etc), but the two are completely disconnected.

    2. Any Java that runs in PeopleCode (jar files, class files) is run on the app server and has absolutely no user interface. It can't. It runs "headless." If Java run in PeopleCode attempts to present a user interface, it will throw the HeadlessException you saw earlier.

    This is why RCC and Hakan suggested using an applet. An applet's Java, however, doesn't run on the App server. It runs on the client. PeopleCode associated with an applet would not call GetJavaClass or CreateJavaObject. Those two functions relate to Java running in the app server. An applet does not run in the app server, it runs on the client.

    When using an applet, a problem that may arise is gaining access to the files you want to compare. The files exist on the app server, which should be separate from the web server. An applet (untrusted) can only compare files that are accessible from the web server. App server files are not accessible through the web server. A trusted applet can access files on other web servers or on the client PC. None of these are the case with app server files. They are protected by the host and should not be accessible through a web server. Through the use of iScripts, however, you can write the contents of an app server file to a browser, thereby making the file accessible through a web server.

    In regards to the ClassNotFound exception, that is thrown if your app server's class path is missing a file (jar or class) file. If the file exists, then the problem may be that you need to restart your app server to load the jar file into the classpath.
  • 7. Re: Execute Java file (jar) on client side
    920441 Newbie
    Currently Being Moderated
    Thanks for your brief explanation Mr.Jim.

    Using Response class i can get the parameters from the webserver using Iscript. When i try to instantiate the java class using javascript, it wont work. ie it does not respond anything. Within the Javascript code i have create an object for java class like,

    <script src=
    "http://www.java.com/js/deployJava.js"></script>
    <script>
    var attributes = { id:'guiffyframe',code:'Guiffy.GuiffyFrame',  width:1, height:1} ;
    var parameters = {jnlp_href: 'Filename1.txt',jnlp_href: 'Filename2.txt'} ;
    deployJava.runApplet(attributes, parameters, '1.6');
    </script>


    for our example, i get input from the user using Javascript prompt. Below code to execute the java classes to compare the files. but the java class does not instantiated and not executed.

    <script language="javascript">
    function enterNums(){
    var File1= prompt('Enter number File name1 with full path");
    var File2 = prompt('Enter number File name2 with full path");

    guiffyframe.set1stFile(&FirfileName);
    guiffyframe.set2ndFile(&SecfileName);

    guiffyframe.compareFiles( True);
    }
    </script>

    can you tell me, what mistakes i have made in my code? please share your further ideas about this problem.
  • 8. Re: Execute Java file (jar) on client side
    920441 Newbie
    Currently Being Moderated
    Hello Jim,

    As per your suggestion i resolved the issue.

    But now i am facing another issue. I pasted my sample code below.

    <html>
    <body>
    <APPLET CODE="fileguiffy.AppletDemo"
    ARCHIVE="ftp://Server1:21/DEV/FileCompareGuiffy.jar, ftp://Server1:21/DEV/Guiffy.jar"
    WIDTH=600 HEIGHT=450>
              alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason.">
                   <param name='firstFilePath' value='c:/test.sql'>
                   <param name='secondFilePath' value='c:/test1.sql'>
              Your browser is completely ignoring the <APPLET>
    </APPLET>
    </body>
    </html>


    from the above code, i have placed my class file in the FTP path. So, if i have used the ftp path it works fine. But my requirement is, java class files need to be place in the webserver directory. then i have to include the webserver directory URL instead of FTP url. Is there any way to find out the webserver URL(webserver directory path) in which the webserver used at runtime.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points