Results 1 to 4 of 4
  1. #1
    raxwer is offline Member
    Join Date
    May 2010
    Posts
    3
    Rep Power
    0

    Default Cant get output of a class file through JSP.

    Hi,

    I am trying to see the output of a class file through the following JSP.

    Java Code:
    <%@ page  import="java.io.*"  %>
    <%@ page  import="java.util.*"  %>
    <html>
    <body>
    <%
     try {
      String line;
      Process p = Runtime.getRuntime().exec("c:\\ProgramFiles\\Java\\jdk1.6.0\\bin\\java Abc");
      BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream()));
      while ((line = input.readLine()) != null) {
       out.println("linbe"+line);
      }
    out.println(input);
        input.close();
       }
      catch (Exception err) {
          err.printStackTrace();
        }
    
    %>
    
     </body>
    </html>
    No output is produced here.
    Here Abc is any class file placed at /jdk1.6.0/bin folder.
    I have given "execute" permission to java.exe in java.policy file.


    Though when i am using getErrorStream in place of getInputStream.
    I get error:: NoClassDefinitionFoundError Exception in Thread Main.

    Please help anyone.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    The error would look like the java cmd does not have a library with the definition for the Exception class. ???

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default

    The cwd (Current Working Directory) is not c:\\ProgramFiles\\Java\\jdk1.6.0\\bin where you class is and that directory is not on your classpath either. Add that directory to your classpath list.

    kind regards,

    Jos

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    Some more ideas: Is java installed properly on that machine? Are the registry entries pointing to where they need to point?

Similar Threads

  1. Replies: 8
    Last Post: 05-12-2010, 08:19 PM
  2. Replies: 4
    Last Post: 04-06-2010, 03:42 PM
  3. Print Variable From One Class to Output on another.
    By Lyricid in forum New To Java
    Replies: 8
    Last Post: 02-27-2010, 02:56 PM
  4. Class problem: getting incorrect output
    By mgm2010 in forum New To Java
    Replies: 9
    Last Post: 04-30-2009, 08:17 AM
  5. Replies: 7
    Last Post: 11-19-2008, 03:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •