aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes disable/enable current network connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "disable/enable current network connection" Watch "disable/enable current network connection" New topic
Author

disable/enable current network connection

serouja louba
Greenhorn

Joined: Mar 31, 2011
Posts: 4
Dear All,
I'm trying to disable and enable the network connection in my java application, i searched a lot how to do it as I'm a beginner but i didn't find a direct implementation in java to do it, i found the best approach is executing the below command:

netsh interface set interface <interface name> disable

but how to get the interface name for a given IP Address?

please help!

thanks
Sergey
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

You can use class NetworkInterface for that.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
serouja louba
Greenhorn

Joined: Mar 31, 2011
Posts: 4
Rob Spoor wrote:You can use class NetworkInterface for that.


sorry, but I tried it and I was unable retrieve the connection name, could you please point me how to get?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Welcome to the Ranch

I think that question is too difficult for “beginning”, and shall move it.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

serouja louba wrote:
Rob Spoor wrote:You can use class NetworkInterface for that.


sorry, but I tried it and I was unable retrieve the connection name, could you please point me how to get?



What have you tried? And what did you get? It works for me.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
serouja louba
Greenhorn

Joined: Mar 31, 2011
Posts: 4
thanks Henry,
I tried to follow the java tutorials http://docs.oracle.com/javase/tutorial/networking/nifs/listing.html, see my code below, please note that I'm using win7:



and what I'm getting is the below:
serouja louba
Greenhorn

Joined: Mar 31, 2011
Posts: 4
Hello JavaRanch, any updates on this topic pleaseeeee!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

serouja louba wrote:Hello JavaRanch, any updates on this topic pleaseeeee!


What update do you need? Your last post showed that it worked for you too. Your interface name is "eth3".

[EDIT] Oh I see... Windows.... .... You need the form that is used by "netsh". Well. one option is to get it from "netsh" via a show interface command. Of course, this will mean that you will need to do an another exec().

Henry
indira vadde
Greenhorn

Joined: Sep 13, 2012
Posts: 1
hai, iam new to this forum and i need a suggerstion.

I have to connect to remote server which is using ssh2 protocol using java application. I am new to java. I have referred the ch.ethz.ssh2.* api but couldnot get any sample examples. Can some one guide in this please.. its dam urgent for me.
Sorry if i posting this toa wrong category.

Thanks in advance...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: disable/enable current network connection