Results 1 to 4 of 4

Thread: Sending string to java process

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 1 Time in 1 Post

    Default Sending string to java process

    From Qt application, starts a java subprocess, and sends a string to it. No need any response from java process.
    I want to use QProcess because i think it is more simple than QTcpSocket(not sure).
    However, it seems the java subprocess cant recieve the string.
    Consider the codes writed below:

    Qt Code:
    Qt Code:
    1. QProcess *java= new QProcess();
    2. java->setWorkingDirectory("F:/");
    3. java->start("java Test");
    4. if(!java->waitForStarted())
    5. return false;
    6. java->closeWriteChannel();
    7. QString str = "Test String";
    8. //qDebug() << qPrintable(str);
    9. std::cout<<qPrintable(str)<<std::endl;
    10. //QTextStream out(stdout);
    11. //out<<str;
    To copy to clipboard, switch view to plain text mode 

    Java Code:
    Qt Code:
    1. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    2. String str;
    3. try {
    4. str = reader.readLine(); }
    5. catch (IOException exc) {
    6. System.out.println("Can't read from stdin!");
    7. return ; }
    8. if(str != null)
    9. System.out.println(str);
    To copy to clipboard, switch view to plain text mode 

    How can i get it work as expected? Any advice will be thankful!
    Last edited by moiit; 7th July 2011 at 15:33.

Similar Threads

  1. [java] string.replace
    By mickey in forum General Programming
    Replies: 3
    Last Post: 7th September 2010, 07:04
  2. Sending signal to other process?
    By Boron in forum Qt Programming
    Replies: 3
    Last Post: 28th August 2009, 09:06
  3. [java] manipulate a string
    By mickey in forum General Programming
    Replies: 5
    Last Post: 10th July 2008, 20:22
  4. Sending string from QT client to Java server
    By seanmu13 in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2007, 12:52
  5. Sending string from QT client to Java server
    By seanmu13 in forum Newbie
    Replies: 3
    Last Post: 3rd July 2007, 12:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.