Re: Switch Network Connections

On Monday 08 of November 2010 08:13:35 Jos Collin-ERS,HCLTech wrote:
> Hello,
> I have a wired and a wireless connections available in my computer. Both of
> them are configured in the NetworkManager. How can I programatically
> choose (or switch) to wired or wireless connection, using java?. After
> choosing a connection my computer should use that particular connection to
> access the Internet.
> I have searched in the NetworkManager spec, but didn't find anything useful
> for doing this.
> By the way, what is ActivateConnection under
> org.freedesktop.NetworkManager? Will it do the job for me?
> Please suggest.
> Thanks,
> Jos Collin

NetworkManager provides a D-Bus interface to communicate with it. The API is 
described by the link you provide, which is for version 0.7. For NM 0.8 use

The ActivateConnection() is the right method to call for activating a 
connection (connect to the Internet) by NM.

You can talk to D-Bus with a number of utilities and languages.
command-line tools: dbus-send, qdbus, ...
D-Dus GUI (debuggers): d-feet, qdbusviewer, ...
languages: python, C, Java, ...

Using dbus-send, the call would look like this:
dbus-send --system --print-reply --dest="org.freedesktop.NetworkManager" 
ettings" objpath:"/org/freedesktop/NetworkManagerSettings/34" 

You can find examples in C and python in NM source tree:

See also this thread:

For Java, you need to use java d-bus binding:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]