Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-03-2008, 05:24 PM
Member
 
Join Date: Nov 2007
Posts: 2
fangzhong is on a distinguished road
calling linux command line in java
Hi guys,
I met a problem about calling linux comand in java program.
In linux, I type :
similarity.pl -type WordNet::Similarity::vector -file /home/csunix/fzsu/exam.txt
it returns:
Loading WordNet... done.
Loading Module... done.
good#a#1 nice#a#1
good#a#1 nice#a#1 0.885813537770033

dog#n#1 cat#n#1
dog#n#1 cat#n#1 0.712603873475428

good#a#6 nice#a#1
good#a#6 nice#a#1 0.822428178005622

From above, we can see that it works well, similarity.pl is a perl program for computing similarity between two concept, and -type and -file are the parameters.

Now I want to use java to call these command, and here is my code:
public static void main(String[] args) {
try{

String command="similarity.pl -type WordNet::Similarity::vector -file /home/csunix/fzsu/exam.txt";
Process p=Runtime.getRuntime().exec(command);
BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=null;
while ((line=br.readLine())!=null){
System.out.println(line);
}
}catch (IOException ex){
ex.printStackTrace();
}

}

But noting is print out. I also add the full path for similarity.pl, like /home/csunix/fzsu/similarity.pl in the variable "command", but still the same.

I also change variable "command" to a string array in this way:

String command[]={"/home/csunix/nlplib/WordNet/2.1-F7/perl/bin/similarity.pl",
"-type","WordNet::Similarity::vector","-file","/home/csunix/fzsu/exam.txt"};

Again, I get nothing from it.
Can anyone point out how to solve this problem?

Thanks,
Joe
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line argument denisatandi New To Java 3 06-15-2008 07:59 AM
Java command line agouzoul New To Java 2 04-02-2008 01:12 PM
Exporting from the command line o1121 Eclipse 1 08-09-2007 08:29 PM
Unable to execute command line command in java LordSM New To Java 1 08-08-2007 01:23 AM
Java Command Line Arguments In Eclipse IDE JavaForums Eclipse 0 05-19-2007 10:45 AM


All times are GMT +3. The time now is 12:01 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org