Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

How do I get the network IP Address with Java  RSS feed

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want network IP Address which should be the same for all computers in a network.
 
Bartender
Posts: 1114
36
IBM DB2 Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but your question is really unclear. An IP address is unique within private network, so what are you asking about ?
 
Alejandro Barrero
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Claude for your reply. Allow me to clarify; if I run ipconfig in every computer in a network I will get a different IP address for each one (perhaps I am wrong and I get the network IP address); I have been searching the Internet for "Network IP address" and some code that some people think works to get it (some use java.net.InetAddress). I am creating a Java desktop application and I want to make sure it only woks in the network where it has been installed.
 
Saloon Keeper
Posts: 5344
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The network IP address will most likely be an internal one like 10.x.y.z or 192.168.x.y - which will not help you at all, because those are used everywhere.
 
Saloon Keeper
Posts: 2476
317
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do something like this to find all the ip addresses associated with the platform:
My desktop:
Be aware that the platform may have multiple network interfaces, and each network interface may have more than one IP address.  Also, as Tim commented, they will often be internal/private addresses, not public Internet addresses.
 
Ron McLeod
Saloon Keeper
Posts: 2476
317
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Alejandro Barrero wrote:I am creating a Java desktop application and I want to make sure it only woks in the network where it has been installed.


If you want to find the public IP address that the platform would use when accessing the Internet, there are a number of open network APIs which you could use.  Here's an example using ipify:
The IP address may not necessarily be the same ever time you check.  If the connection to the Internet is using DHCP, or if there are multiple connections to the Internet (for load balancing, failover, etc.).
 
Everybody! Do the Funky Monkey! Like this tiny ad!
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!