Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

RunTime class

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea if I'm posting in the current forum section, if I'm wrong forgive me and/or move the thread.

My question is as follows : I want to open a torrent file from my HD using a BTClient of my choice, BitComet, Azuerues whatever.

I understand it can be done with RunTime.exe, but I'm having problems with that.
Currently I'm running the following code-



BitComet does open up, sometimes it starts downloading my torrent file, sometimes it does nothing.

Could someone help me understand better what happens? Any comments will be appreciated.

Thanks in advance.

p.s btw how can I learn about commands that can be passed to this runtime class? it is not documented at the class API.
[ October 18, 2008: Message edited by: Patrick Brahami ]
 
author & internet detective
Posts: 41263
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Patrick,
Are you capturing the output of the command? (see example) If so, does it give any error messages when failing to run?

how can I learn about commands that can be passed to this runtime class? it is not documented at the class API.


What are you looking for in terms of this? You can pass any valid command line string and arguments that your operating system supports.
 
Marshal
Posts: 76492
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And of course nobody should even think of going near Runtime.exec without reading the classic article by Michael Daconta.
 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes but I'm unfamiliar with system commands. How can I find out more about that?

Btw, what does "/s" means exactly?
If I run the code as in my first test with BitComet the torrent starts to download.[I solved the problem, it was me giving a wrong location of the file.. "/" was missing ]
But now if I run it with Vuze (Azuereus) it doesn't. It gets stuck while loading Vuze, it continue only after I close my program.
And then it opens a window "/s" is not a torrent, or something like that.

I wonder how come it works perfectly with one BTClient and won't with the other.

Thanks in advance.

[ October 19, 2008: Message edited by: Patrick Brahami ]
[ October 19, 2008: Message edited by: Patrick Brahami ]
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Patrick Brahami:
Yes but I'm unfamiliar with system commands. How can I find out more about that?



Read your OS' manual. They are not Java specific. They are operating system specific.

Originally posted by Patrick Brahami:
Btw, what does "/s" means exactly?



It is a switch used by BitComet. Look up the BitComet manual for what it means.

Originally posted by Patrick Brahami:
If I run the code as in my first test with BitComet the torrent starts to download.[I solved the problem, it was me giving a wrong location of the file.. "/" was missing ]
But now if I run it with Vuze (Azuereus) it doesn't. It gets stuck while loading Vuze, it continue only after I close my program.
And then it opens a window "/s" is not a torrent, or something like that.

I wonder how come it works perfectly with one BTClient and won't with the other.



Apparently '/s' is not a valid switch for Vuze, you will have to find out what it means in BitComet and then find out comparable functionality with Vuze, and any other clients. Because each BitClient will be different, and expect different parameters and switches the commands you pass into Runtime will be client-dependent. You will need to know what each one expects and use them appropriately. You will have a completely different array of commands for each client, not just a different executable name/location.

p.s. The fact that your application hangs until after you close your Java app, then Vuze tells you that there was a problem it tells me you did NOT read and implement the article Campbell linked to the last post. You should do that. It is imperative.
[ October 19, 2008: Message edited by: Steve Luke ]
 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed I did not read it. I am going to read it right now.
What is a switch? Something the application creates so people will be able to communicate it?
How can I find out what Vuze uses? I mean what should I search for? Vuze switches?

Sorry for my ignorance but I'm really unfamiliar with this stuff.
K, going to read the article hope it'll help.

Thanks for your comments, as always.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Patrick Brahami:
Indeed I did not read it. I am going to read it right now.
What is a switch? Something the application creates so people will be able to communicate it?
How can I find out what Vuze uses? I mean what should I search for? Vuze switches?

Sorry for my ignorance but I'm really unfamiliar with this stuff.
K, going to read the article hope it'll help.

Thanks for your comments, as always.



A switch in this context would be some parameter that a command line application accepts to make it act a specific way.

Some examples in Java:
When you want to compile a java application you usually use the command:

But if you wanted to get the version of the java compilet you would use the -version switch:

And instead of trying to compile it will tell you the version number.

How do you know what Vuze uses? Vuze may not use any, you will have to look up any documentation the application comes with (readmes, user guides, anything and everything). If it doesn't come with any docs then ask Vuze customer support or contact the developers. If they don't have customer support then you can try asking the application by passing some common 'help' switches like /h /help /? -h -help or -?. If you can't find a help switch then try finding some forum where you will likely find Vuze users and ask if there are any switches.
 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see.
I found out a vuze command line documentation here -
http://www.azureuswiki.com/index.php/Commandline_options
but I am not sure if what I want is there, and how to exactly use it to write my command.

Someone knows?
 
Campbell Ritchie
Marshal
Posts: 76492
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try running Runtime#exec with something simple, and see how it works. then try adding flags. I think Daconta's example (quoted earlier) shows how to invoke java and javac.
 
Patrick Brahami
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you give me examples for what would you try?

I tried few basic commands, but since I'm unfamiliar with it I feel insecure about their correctness.

Thanks in advance.
 
Campbell Ritchie
Marshal
Posts: 76492
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Difficult to know what to suggest. Try Daconta's examples, which I think mean invoking "javac" and "java."
On Linus I would try something like "firefox" or "opera" to launch browsers.
On Windows you can find the path to an application by right-clicking its desktop shortcut and reading its properties.
Try launching Internet Explorer, which is actually called something like IExplore.
Try one of your other installed programs. How about a word-processor; see what happens if you write a letter.
Or the calculator applet.
Once you have got them working, back to "java" and "javac" which can take options and command-line arguments, and get them working.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about you give examples of what you tried, and what the results were. Then compare the results with what you wanted.
 
Hey! You're stepping on my hand! Help me tiny ad!
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic