Win a copy of Kotlin for Android App Development this week in the Kotlin 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 1093
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: 5235
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: 2353
293
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: 2353
293
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.).
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!