Runing java pogramfrom Servlet

Hi everbody
I was trying to execute and run ajava program from servlet. It seems to me the servlet can compile the code but it is not capable to execute it. I have tried to save the class file in a bat file after the servlet compiled it but it did not work. any help will be appreciated.
try{
String[] command = {"javac","c:\\class\\test.java"};
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(command);
catch(Exception ex){  }
try{
String[] command = {"java","c:\\class\\test"};
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(command);
catch(Exception ex){ }

Hi !
I'm having the same problem. But in my case, it's an attempt to execute a Jini program (which I must execute with runtime flags, kind of -Dhostname=MyHost, etc).
However, I managed to execute a Java program without passing to it the runtime flags:
1. with Class.forName (ClassName)
2. with new ClassName
With Runtime.getRuntime ().exec () I get exitValue () equals to 1 (when 0 = OK). I don't really know what should be configured in Tomcat so that this works...
Hope this will be of any help to you.

Similar Messages

  • Compile java applications,servlets etc.

    I am a newbie to java...what do i need to compile java applications,servlets etc.

    first you need java developers kit(jdk)
    download it
    then r.click on my computer and take it's properties
    go to advance properties
    go to envirinment variable
    set variables
    JAVA_HOME set to directory where you installed jdk
    CLASS_PATH set to the bin in your jdk
    then write a java class and save somewhere as .java file
    go to command prompt
    change directory to where you save java class
    and use javac (yourjavafilename) .java command to compile it
    wish you all the best

  • Runing java pogram from Servlet

    Hi everbody
    I was trying to execute and run a java program from servlet. It seems to me the servlet can compile the code but it is not capable to execute it. I have tried to save the class file in a bat file after the servlet compiled it but it did not work. any help will be appreciated.
    try{
    String[] command = {"javac","c:\\class\\test.java"};
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(command);
    catch(Exception ex){ }
    try{
    String[] command = {"java","c:\\class\\test"};
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(command);
    catch(Exception ex){ }

    Don't cross-post your questions, please.

  • Pre mature termination of Java Program (Servlet)

    Hi,
    Any One can help me for the above subject
    i have my application on java servlets/JDBC on linux (red hat 6.2)
    with Oracle 8i 8.1.6 we we fire a application which invloves some big table (10) and millions of row after 30 to 35 minutes my java application dies pre maturly.
    i have 250 MB SGA and java settings in init.ora are as
    java_pool_size = 50M #20971520
    java_max_sessionspace_size = 90000000
    java_soft_sessionspace_limit = 90000000

    You use the java in the DB?
    We makes DB connection thru java class.
    What kind of Class do you use for Insert?
    Class.forName("oracle.jdbc.driver.OracleDriver")
    Do you use PreparedStatemend with addBatch over all Rows or do you set commit after every rows?
    Yes we are using PreparedStatemend and committing after each row.
    Do you get an exception?
    No we do not get any exception.

  • How to compile a java file(Servlet) in J2EE v1.3.1

    This is my first time using J2EE instead of J2SE!!HOw to compile a java file in J2ee\bin because there is no javac in j2ee and when i compile in J2se i got
    G:\j2sdk1.4.1_01\bin>javac HelloServlet.java
    HelloServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    This mean it doen;t support servlet in J2se!!so how can /what command to compile a servlet java file in j2ee.Thanks

    You'll need to add the j2ee.jar to your classpath. Usually you'll have to add some jars from your app server to your classpath as well.
    For example (using weblogic):
    javac -classpath c:\java\j2ee\j2ee1.3.1\lib\j2ee.jar;c:\tools\appserver\weblogic\wl7.1\lib\weblogic.jar
    HelloServlet.java

  • Palin old java class Servlet Communication issue

    I am sending data to servlet and able to get back data to plain old java class using url.openConnection mechanism.But I want to redirect another jsp page after servlet get data from java calss.
    Can any one help me please
    Regards
    Madhu

    What alternative could there be?
    You're calling a webserver which just happens to be running a Java process to generate its output.
    You don't have to know that, that's the whole point in using servlets...
    So no, there's no way (and if there is it's a terrible breach in the security of your server).

  • Java bean servlet

    is it possible to access a bean in servlet ?
    if yes ...
    please solve my problem
    i am trying to access a form data from html page..
    simple form
    <form method="post" action="Beanservlet" >
    <input type="text"  name=username >
    </form>BeanServlet.java
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import use.UserData;
    public class BeanServlet extends HttpServlet
         protected void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              UserData ud = new UserData();
              String st =ud.getUsername();
              out.println(st);
         protected void doPost (HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
              doGet(request,response);
    }Bean Class
    package use;
    public class UserData {
        private String username;
    public void setUsername( String value )
            username = value;
    public String getUsername() { return username; }
    }in my beanservlet page i got null instead of printing the value i accessed from html ..
    null

    UserData ud = new UserData();
    String st =ud.getUsername();
    out.println(st);
    do u know what u were doing on the above code? u're trying to create an instance of UserData without setting any value into its properties, and then you get the username from this empty instance, surely you will get null for the name...
    in order to retrieve data from a jsp page, u'll need to ensure that u're using a form, and the data u intended to retrieve is specified inside this form. and then, in your servlet class, doGet method, use HttpServletRequest.getParameter(String name), where the name is the name you specified in the input tag. once u've done that, it should display the name correctly....
    hope this help.

  • How to instance handler.java into servlet

    Hi
    I don't have much experience in servlet.
    I want to instance a handler.java which connects to database and has all sort of methods into a servlet. But I don't know how to do it as servlet is different from normal java files or jsp .
    Can anyone help?
    Thanks
    M

    A servlet is just a normal Java class and you can instanciate Objects in the Servlet like you would in any other Java class. That is import the class, declare the reference and then do a new on the class.
    The only caveat is that Servlets are multi-threaded so it is best to not have any class level objects unless they are thread safe.

  • Java, JSP, Servlet....!!!!????Can you help me?

    Hi all,
    Now I want to use Java (JSP, Bean, Servlet and EJB) for programming (application/web/internet/database). Which architects I should use?
    JSP --> Database.
    JSP --> Beans --> Database.
    Servlet --> Database.
    JSP & Servlet --> Database
    JSP & EJB --> Database...
    Can I use COM/DCOM such as ASP pages?
    And which databases (SQL Server, Oracle, Access, DB...) I should use? Which web servers (Jrun, JWS, Apache, JWS, Orion...)?
    Are there some stuff on Internet relate to this topic (some samples)?
    Thanks so much.

    Hi all,
    Now I want to use Java (JSP, Bean, Servlet and EJB)
    for programming (application/web/internet/database).
    Which architects I should use?you can use the Model-View-Controller or MVC model.
    Model = JavaBeans --> for your business logic/process
    View = JSP --> for your presentation like HTML
    Controller = Servlet --> as your router or dispatcher of the JSPs.
    And which databases (SQL Server, Oracle, Access,
    DB...) I should use? for large business applications that would require security, optimization, etc., i suggest that you go for a good dbase and i'm referring to Oracle, SQL Server, Sybase, Informix, and the likes. But, if you're going to do simple application, MS Access can do the job. Since it comes with MS Office installation, you'll not find it any harder to configure your dbase.
    Which web servers (Jrun, JWS, Apache, JWS, Orion...)?you can use the following apache, IIS, Websphere, etc...
    don't forget that you also need an application server. say, tomcat application server and apache web server.

  • Seeking recommendations for Java and servlet tutorials

    I am newbies in Java, except knowing some JavaScripts, JSP for web programming. Currently, I am using PHP, MySQL, Apache, and now I would like extend my skills to Java.
    I visited the java website, it seems to have many different packages and tech for different requirement. What should I learn for web programming? And which database is mostly fit for Java language? Mysql? oracle?

    If you want to do web programming, JSP and JavaScript is a good start. You'll also need to know servlets. Since you are new to Java, you'll also need to learn some of the basic classes. I would start with Sun's Java tutorial and when you have mastered that move on to their J2EE tutorial and focus on the chapters that deal with servlets, jsps and related technologies. The J2EE tutorial will include other topics that you may not want to learn right now.
    All major relational databases can be used with Java. The JDBC api can be used for all of them. There might be some minor differences in how you code you queries but the way you do things is the same regardless of the database.

  • Conversion of Vedio file to FLV using Java/JSP/Servlets/Struts

    Hi all,
    This is N.Sridhar and I am working on file transcoding.Does any one have any idea about video conversion tools/API which can be used to programitically with JSP/Servlets/Struts or Java to convert any video file to FLV so that it can be viewed in the Web Browser.Kindly let me know if any one of u have worked on it.You can also get me at [email protected]
    Thank you all
    Sridhar.N

    Hi all,
    This is N.Sridhar and I am working on file transcoding.Does any one have any idea about video conversion tools/API which can be used to programitically with JSP/Servlets/Struts or Java to convert any video file to FLV so that it can be viewed in the Web Browser.Kindly let me know if any one of u have worked on it.You can also get me at [email protected].
    Thank you all
    Sridhar.N

  • Web Server in Java- Running Servlets and JSP files?

    I am developing a web server in java. i wish to execute server side tools(jsp and servlets) in this web server. how i can add this functionalities to this server? is any tools in java are available for running these?

    There certainly are. Perhaps the best known is Tomcat, part of the Jakarta project at http://jakarta.apache.org.

  • Why using JDeveloper runing java program is faster

    I have written a java program by JDeveloper 3.0, press run button to run the java check
    the performance.
    and then close JDeveloper, try to run the java program only on NT workstation.
    I found that the performance is lower than
    running inside JDeveloper.
    Why the reason ?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rob (JDeveloper Team):
    If you are running under JDK 1.2, then the reason is that internally JDeveloper uses the OJVM (Oracle Java VM) which is faster than most other JVM's on NT. You may wish to try your app with the JDK 1.3 rc2 from the Javasoft website (which uses HotSpot) and will be faster than the stock JDK 1.2.
    <HR></BLOCKQUOTE>
    Is compatiable using SQLJ for HotSpot ?
    and if not using HotSpot
    Can I uses OJVM only to run my program ?
    How to do ?
    Thank you
    null

  • Embedding a java application (servlets) in a portlet

    Hi all,
    We have an existing java application that we want to run as a portlet in our portal internet site. The application is a simple search form, which submits parameters (search criteria) and returns results, from there can click on a few other things and open some documents etc. We want all this to happen in the same portlet window, rather than opening out to a new window. Can someone please advise if this can be done? We are running release 1 of 9IAS (and we can't upgrade to rel 2 yet) with PDK March. We would preferably like to do this without touching/reprogramming the java code. I have seen a couple of conficting posts in this forum about this - some say can be done, some say can't be done. Please advise:
    1. Is there some kind of wrapper that can be applied to keep this app inside the portlet?
    2. What other alternatives are there to getting this java app inside?
    3. Are there any step by step guides to doing this?
    Any help would be much appreciated. Thanks heaps, Sarah

    I have tried the URL services, it displays the page fine within the portlet. Just one problem though. The links that are embedded in the HTML will open new windows when clicked. We want them to stay within the portlet. Does something need to be changed in my xml file? I have
    <renderer class="oracle.portal.provider.v1.RenderManager">^M
    <showPage class="oracle.portal.provider.v1.http.URLRenderer">^M
    <contentType>text/html</contentType>^M
    <pageExpires>60</pageExpires>^M
    <pageUrl>http://www.oracle.com</pageUrl>^M
    <filter class="oracle.portal.provider.v1.http.HtmlFilter">^M
    <headerTrimTag>&lt;center</headerTrimTag>^M
    <footerTrimTag>/center></footerTrimTag>^M
    <convertTarget>true</convertTarget>^M
    </filter>^M
    </showPage>^M
    </renderer>^M
    perhaps I need a different renderer? I saw another post had something in the xml :
    <inlineRendering>true</inlineRendering>
    that looks promising. Will that deliver the results I'm looking for? Where does it get added?
    Thanks for any replies. Sarah

  • Java XML servlet

    hii all
    i am querying an XMLobject in the servlet from the database.
    now i want to send the array of this XMLObject to a JSP page and display the attributes.
    also please note that it is not needed to display an XMLFile , insted i want to show array of XMLObject , each object in a single row in a tabular format.
    please help ....
    thanks

    hii all
    i am querying an XMLobject in the servlet from the database.
    now i want to send the array of this XMLObject to a JSP page and display the attributes.
    also please note that it is not needed to display an XMLFile , insted i want to show array of XMLObject , each object in a single row in a tabular format.
    please help ....
    thanks

Maybe you are looking for

  • NHL Gamecenter Premium Upgrade on Samsung Galaxy TAB 2 Tablet

    For the past 4 days, I have been trying to get the premium upgrade on my tablet. During this process I have been on the phone with NHL support 3x and been DMed by VZWSupport through twitter. Nothing has been resolved at all. When I install the app (Y

  • Excise Tab in MIGO for import PO

    Dear all When doing MIGO for Import PO excise tab is not appearing for the material I have maintained all the data in J1ID for the material and plant already we use to capture EI for the same material and plant but this time this is creating issues W

  • Can i buy a case for my macbook pro late 2011 that is for retina display macs?

    i want to buy a case for my macbook because its starting to get more scratches at the bottom. i was thinking about getting this one: http://www.amazon.com/GMYLE-Turquoise-Rubberized-Transparent-Protective/dp/B0098 USJJ2/ref=sr_1_1?ie=UTF8&qid=1379609

  • Finished Goods valued at Future Standard price at the time of Delivery .

    Hi, My client requires the Finished Goods to be valued at Future Standard price at the time of delivery from Production order. This is required because in case there are frequent changes in the material prices, i can mark my material several times..

  • Problem in adding "Reason for Rejection" using BAPI_SALESORDER_CHANGE

    Hi all,        I have a requirement to stop further processing of sales order by changing the reason for rejection at line item. I have done the code and passed the reason code in the item table to BAPI. The return message says the sales order ammend