• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

dynamic java

 
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
what i'm trying to do is execute some simple java code dynamically from a jsp page and display output into this page.
I need to load a java program (this one should contain a main() method) and run this program. get output from this program.. and then display result to jsp page. for example :
test.java
---------
public class Test{
public static void main(String[] arg){
System.out.println("hello");
}
}
----------------
now from a servlet /jsp page i should run test.java which will display "hello" ...i.e "hello" should be displayed to the webbrowser in the jsp page. (should be done for any java program dynamically)

any Ideas on how to tackle this problem ?
thanking you.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you must call them via the OS, look at Runtime.exec:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html

Why wouldn't you want to just instanciate the objects and call their methods?
 
Marshal
Posts: 67280
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't work that way. When you activate a separate Java program, it will send its output to System.out like any other Java program.

Since you're already in a JSP page, why the need for a separate program?
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replying...
i'm developing a web application for online compilation and execution of java programs...user clicks a button and a java program should compile and execute...the problem is that my java progs sends output to System.out ..but i want to be able to get this output and display it into my web page...i suspect this involves using some technique to redirect output depending on which Thread is currently running.

I would appreciate any Help to solve this issue.

thanks.
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!