• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help Needed in Applets....Urgent

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am stuck with a problem. Please help me out.

The requirement is :
I have an applet which has to run an executable which produces a .txt. The applet should use this .txt to produce its output.

I made the applet into a signed jar and ran the executable to produce the .txt . But the .txt is outside the jar file and I am not able to use it to create the result.

How do I use the .txt now?? Is the method that I am trying proper or should I use some other method?

Another doubt is, when I run the .html of the applet code (which is in the server), is it cached in the client???
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The executable runs on the client, and the file ends up on the clien thard disk? In that case you can just use the java.io classes to access it like any local file, since the applet is signed. (The jar file is anyway on the server, and has no role in this.)

The HTML page may be cached (that depends on the browser settings), but you influence that to a degree with the HTTP headers (or http-equiv meta tags) mentioned on this page.

To get the most out of JavaRanch, we have a page on HowToAskQuestionsOnJavaRanch, particularly UseAMeaningfulSubjectLine and EaseUp.
 
Neo Wills
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Iam sorry about the subject line. Ill take care of it in future..
About the post, the executable is not in the client end but is in the server end and hence the .txt is also in the server end but outside the signed jar (which has the applet and is being executed).

Thanks for the reply,
Bharath
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm curious how the applet starts an executable on the server, but that's really immaterial to your question.

The applet can download the file from the web server, as long as it's in a publicly accessible directory. Since it's just text, it could be as simple as
 
Neo Wills
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The applet is in a signed jar and the directory where the jar file is has the executable as well.
The applet has been coded using Runtime exec to run the executable and produce the .txt in the server directory.
 
Neo Wills
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me explain it in a much clearer way:

There is a java applet in a signed jar in a file server. The file server also has the .html to access the applet. The directory where the .jar is present has the .exe file. (.html, .jar and .exe are in the same directory)

Now, when the client system accesses the .html in the file server, the applet is invoked which runs the .exe in the same server directory and creates the .txt file in the same server directory. But it is created outside the .jar file and hence the applet can use it to generate the result.

Thanks,
Bharath
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that's what you said before, but it still doesn't explain how the applet can run an executable on the server - anything the applet runs via Runtime.exec will run on the client. So, how does the applet run something on the server? But, as I've said before, that doesn't even matter with regard to your problem. The problem as you've described it is that the applet needs to read a file on the server. My previous post explains how to do that - when you tried that approach, what problems did you encounter?
 
Neo Wills
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get what you said about the file reading.. Will try it now.. But for the running of the executable, how do we determine what a client is and what a server is? If i access the .html on the file server through a remote machine via its URL, the remote machine is the client right?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "remote machine" is the "server." The machine where the user sits with their web browser is the "client".

An applet's Java code runs on the client machine. Runtime.exec() can only execute applications on the client machine. Perhaps you've gotten this to work (sort-of) in a test environment where the client and server are the same machine; but in deployment, they'll be separate and this can't possibly work.

To run an executable on the server, you must have code that runs on the server. One possibility is a servlet. Do you know what those are? The servlet could run the executable, load the text file and send it down to the applet on the client machine.
 
Neo Wills
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Yes. Thats the same mistake I made... I was working on the test environment. Now I tried it on separate machines and it did not work. So now, Ill have to use JSP right?? To run the JSP on the server, will a file server do or should it be a web server?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A file server won't do. And a web server (like Apache) will only do if it is hooked up to a servlet engine (like Tomcat) somehow. It may be easier to just use Tomcat, instead of trying to set up an Apache/Tomcat combination.
 
reply
    Bookmark Topic Watch Topic
  • New Topic