capture the ouput!

Hi,

my perl script is calling another external java program. The Java in turn prints out a string. how can I capture the string.
------------------
#!/usr/bin/perl

print "Content-type:text/html\n\n";

use CGI;
$query = new CGI;
$theCookie = $query->cookie('someCookie');
$user = system("cd /some/location;java myJavaClass $theCookie");

--------------------------
Java is writing the string to the browser. I want to store that string to a variable so that I use it in perl

Thanks in advance