• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to release & renew IP address  RSS feed

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to be able to have a java program release and renew IP address for my computer(using dhcp). I am running windows 98. I want it to work like the winipcfg program. Any ideas to get started would be great.
thanks,
Dean
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dean,
You can use exec() to run dos commands.
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html
Good luck!
Michael
 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My mistake, I want to have the functionality of winipcfg, such as release all and renew all IPs, I did not mean run the program. I need to know how I can release and renew my IP address, I run windows 98.
thanks,
Dean
 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you are talking about creating a Java wrapper for some Windows API calls, I don't see how this can be done. It would imply that the Java API has hooks into the Windows TCP/IP stack, and I don't think that it does.
Of course, you might be talking about writing a Java network client that can somehow get its own IP address from a DHCP server. But that probably involves talking directly with the network interface... again, I don't think that can work in pure Java.
PCS
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use InetAddress.getLocalHost() method defined in the java.net package.
 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Shyam Purkayastha:
You can use InetAddress.getLocalHost() method defined in the java.net package.


This will only retrieve the hostname and IP address of the localhost (if permissions allow), and will not interact with the actual interface or DHCP server.
PCS
 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip
Can you please tell me what is a DHCP server.
regards Shyam
 
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dynamic Host Configuration Protocol.
 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok,
I was able to use the Runtime.exec("winipcfg /releaseall");
which does release my ip, however this brings up the winipcfg screen and when I try to call the
Runtime.exec("winipcfg /renewall");
it has no affect because the release all screen is active.
Any ideas, I would like to do it in like silent mode but can not find a way to do it?
 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I was able to use the Runtime.exec("winipcfg /releaseall");
which does release my ip, however this brings up the winipcfg screen and when I try to call the
Runtime.exec("winipcfg /renewall");
it has no affect because the release all screen is active.


This is because you are using the GUI version of the command. You need to use the command line version. I don't know exactly what this is on Win98, but it may be like "ipconfig /release" (that's the Win2000 version -- on Win98 it may be "ipcfg" or something). Try it at the command line, and you'll see what I mean.
PCS
[ November 25, 2002: Message edited by: Philip Shanks ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!