Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

running Jar file in back end of webserver

Thread view: 
shabbir_a@yahoo.com - 19 Apr 2007 16:53 GMT
Hi,

is there anyone who can help with this problem.  I have a piece of
java software that is sitting on my webserver.  I can run the jar
file from within the command line and it returns a series of results
to the command line. I also have the source code for this app.  

What I want to know, is from within a webapp, can I access this java
app, send it some variables and then pickup what it usually outputs?

If I can, how?

Thanks in advance.

--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -
Kai Schwebke - 19 Apr 2007 17:57 GMT
shabbir_a@yahoo.com schrieb:
> is there anyone who can help with this problem.  I have a piece of
> java software that is sitting on my webserver.  I can run the jar
[quoted text clipped - 5 lines]
>
> If I can, how?

It may be easier to use the classes of this app directly instead of
using the entire app as "black box".

If not, you may use this code to embedd a java console app:

// redirect standard output
java.io.ByteArrayOutputStream captureOut =
  new java.io.ByteArrayOutputStream();

// flush system out and bind to capture buffer
PrintStream oOut = System.out;
PrintStream nOut = new PrintStream(captureOut);
oOut.flush();
System.setOut(nOut);

// call java app's main method
my.little.java.command.line.app.Main(/* arguments as String[] */)

// close capture buffer, reassign original system out
nOut.close();
System.setOut(oOut);

// write captured bytes (optional)
oOut.write(captureOut.toByteArray());

// captureOut.toString() == output of main

You may catch to much output, if other threads write to System.out
as well. Normally a web app should not do this, but use a logging
facility instead.

Kai
shabbir_a@yahoo.com - 19 Apr 2007 21:22 GMT
Thanks for the info Kai.  You mentioned I can call the class
directly - I am new to java, so am not sure how to do this - can I
call the class directly from within a jsp page?  Is the ability of a
jsp page a reduced version of java?

Thanks for the help.  

--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Beta 2
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.