Take the 2-minute tour ×

I am working on a program to handle connections in Ubuntu. I am currently doing it in Java, but aim to do it in C++ too. Essentially, atm I am just running system commands through Java:

proc.exec("ifconfig wlan0 down"); etc.

I get some printout saying it is 'deconfiguring interfaces' and 'fail' is printed out. First off, does anybody know why?

Secondly, can anyone think of a better way of doing this? In the end, I want the program to have the computer run an Ad Hoc network, drop the connection and connect to another network, and pick up the Ad Hoc again when it is done with the other network.

Thanks in advance!

share|improve this question
You're not really giving us a lot of info to work with. Are you running the program with root priviledges? –  Timo Geusch Mar 17 '11 at 16:40
I think the fail issue was due to me not writing sudo -i before the commands. Thanks for pointing that out! –  Christopher Gwilliams Mar 18 '11 at 8:42
add comment

1 Answer

up vote 0 down vote accepted

Probably you can try to interface NetworkManager, which uses D-Bus as its interface, and there exists Java implementations of the protocol.

share|improve this answer
Thanks, just downloaded and looks like it should do what Im after. Felt a bit inefficient to have a program run through terminal commands, a lot harder to detect or handle errors! –  Christopher Gwilliams Mar 18 '11 at 8:44
add comment

Your Answer


