• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

disable/enable current network connection

 
serouja louba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use class NetworkInterface for that.
 
serouja louba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50180
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I think that question is too difficult for “beginning”, and shall move it.
 
Henry Wong
author
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
serouja louba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello JavaRanch, any updates on this topic pleaseeeee!
 
Henry Wong
author
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic