How To Find Ip Address And Mac Address From Another Computer
Nov 12, 2014I want to ask how to track ip address and mac address of a different computer using java?
View RepliesI want to ask how to track ip address and mac address of a different computer using java?
View RepliesI wrote a Chess game that uses socket to connect to another computer, and allow player vs player and player vs computer game sessions.
However, there is a problem which I noticed.
When you get the IP address of the computer in which the program is running, you are not getting the computer's actual IP, you are getting the Router's IP.
Is there a way to get around this.
So the problem is that when I go to another computer, located in a different house or lets say from my school, the program cannot connect back to my home IP, because it uses the router's ip, not the computer's ip I am running the server program.
Is there a way to get the Computer's IP, not the router's ip when summoning or invoking the get IP address method from the socket class?
When I say that the socket class is acquiring the router's ip, well that's done without my interfering...I don't know why it does that, it is somehow recognizing the router and not the computer.
The thing is that the server program is written that any client program is able to connect to the home server.
But when I run the program from a different location other than the current home, the sockets don't connect because it is somehow recognizing the router's ip not the computer's ip.
In my java program I'm changing my IP(using proxy) and sending the request to some sites. Later some point of time, I want to know my current IP address through java program itself. How to get hold of my current IP address? Also which IP address will it show? The proxy one or the original IP ?
View Replies View RelatedI just started using java because i want to create a simple web service that will take some values from within a url and save those values in variables.
To be more specific:
For my project I use the Spring Tool Suite.
I want to be able to enter a URL in a browser.. something like "localhost:8080/test?name=Root". When I hit Enter a page will be displayed showing "Hello Root" if the name in the URL is Root or "Hello User" for any other name.
I accomplish that with this code:
Java Code:
String UserName = "Empty";
@RequestMapping("/test")
public @ResponseBody String username(@RequestParam(value="name")String name){
if (name == "Root")
UserName = "Hello" + name;
else
UserName = "Hello User";
return UserName;
} mh_sh_highlight_all('java');
My problem is that it if I enter Root as a name in the URL it doesn't recognize it and it shows "Hello User".
I tried Java Code: << if (name.toString() == "Root") mh_sh_highlight_all('java'); but no luck.
How exactly I should reform this code in order to make it work?
I am trying to build an address book, and I started from what i know how to do.
public class Persona {
String nome;
String indirizzo;
int cellulare;
public Persona(String nom, String ind, int cel) {
nome = nom;
indirizzo = ind;
cellulare = cel;
[code].....
Now I would like the program to take a string I insert on command line (for example java Cerca"Robert Baratheon") and compare it to the nome field of every Persona in the address book.
When i type following URL....in address bar and press enter,it automatically shows URL...Why does this mean? URL....I am using tomcat.
View Replies View RelatedI need a java program for getting name and address matching from oracle database. I need get all the customer name and address belonging to same person even if there is slight name and address changes are there.
James Smith
123 Broadway Av
Brownville, ME 04415
James S
123 Brodway Avenue
Brownville Junction, ME 04451
I am unable to get a best code for this and trying since long time.
I'm Fresher and i'm new in ATG nd right now working on checkout module.Here I'm trying to take shipping information of user so it is fetching in the shipping information JSP bt when i'm trying to submit that JSP den it's not going to either in SuccessURL or in ErrorURL it's remaining in current JSP.
I'm doing any customization's i'm jst using al Out Of Box Components nd my code is almost same as Out Of Box Code and it is not giving any error also.
I'm attaching my JSP's
Attached File(s)
shipping_jsp.txt (4.17K)
Number of downloads: 293
shippingAddress_jsp.txt (1.9K)
Number of downloads: 135
shippingSingle_jsp.txt (70bytes)
Number of downloads: 19
shippingSingleForm_jsp.txt (2.05K)
Number of downloads: 102
I am designing an address book. I have come up with the following design:
Address Book:
Attributes : Entry
Methods: add(), delete(), search()
Entry:
Attributes : Name, Address, Phone Number
Methods: addName(),editName(),deleteName(),addPhone(),editPhone(),deletePhone(),addAddress(),editAddress(),deleteAddress()
Name:
Attributes: firstName, lastName
PhoneNumber:
Attributes:areaCode, phoneNumber
Address:
Attributes:streetNumber,streetName,city,zip.
I need to make this program work. It is supposed to count the words contained in the Gettysburg address. I went wrong somewhere but don't know where.
import java.util.Scanner;
public class gettysburgAddress {
public Static void main(String[] args) {
String URLString = "http://cs.armstrong.edu/liang/Lincoln.txt";
[Code] .....
I found out what my next java class project is, and i am trying to get a head start on it. It is a simple address book. it needs to have 4 choices that get cycled through until quit is chosen:
1. add business contact
2. add personal contact
3. display contacts
4. quit
I have made an abstract contact class with a personal subclass and business subclass(all 3 are required). they have all been made, with set/get methods(the wonders of encapsulation and polymorphism have finally hit home!). The main program needs to add a new subclass object when chosen, and it needs to accept and store contacts by type
So, i am figuring 2 object arraylists for business/personal.
My question is: how do you create an object without having a name for it already programmed? Does it even need to have a unique name, since it would be stored in a seperate index and/or arraylist?
Contact contact = new Contact();
this.firstname = "Be";
this.secondname ="Ginner";
this.phonenumber = "921-456-0102";
personalArray.add (contact);
Then cycle through, changing the properties, and add again to personalArray?
how should i write appropriate methods to get user info like age, email address etc?
View Replies View Relatedi found a code to get emails from gmail in this forum.It's working very well, now i want to delete a specific sender email address.
So i can have the sender email with this:
Java Code: String senderAddress = aMessage.getFrom()[0].toString();
System.out.println(" From: " + senderAddress); mh_sh_highlight_all('java');
Now i want to do something like
Java Code: If (senderAddress = "test@gmail.com"){
message.setFlag(Flags.Flag.DELETED, true);
} mh_sh_highlight_all('java');
but it's not working.
I have a question about arraylist objects.... I want to create an address book that will contain a persons information (name, phone, address, email..etc..). The first two snippets of code are from the same class ContactArrayList and the last one is from the class Contact. Do I need to create a separate arraylist for each data type? Is it possible to use a single arraylist to contain all the object (person) information and then be searched for using a GUI? I would also like to be able to access this data to be manipulated using a JFrame (add, edit, and search).
public class ContactArrayList<E> implements List<E> {
public int size, capacity;
E contact;
private E[] contacts;
public ContactArrayList() {
size = 0;
capacity = 20;
[Code] ....
I wanted to ask is there any way that Java code can get at the address of some object or other datum? I've found this useful a few time with certain high performance C# libraries that I've developed.
Also does Java have the equivalent of C#'s "fixed" buffers? which are inline contiguous arrays of primitives (like Chars or Ints etc).
I am trying to implement an example (Book* : Java SE 7 ..By S G Ganesh) for validating an IP address but it fails to validate a valid IP addresses. I found another example on the internet(**) and it works super fine, no problem at all. I edited the code (the one I got from internet) into the exact format like book and it still works super but i don't understand why the books' example doesn't work though both look exactly the same now ,further more, how can i compare String x and y for equality?
public class TestClass {
void validateIP(String ipStr) {
String one = "((25[0-5]|2[0-4]d|[01]?dd?)(.)){3}(25[0-5]|2[0-4]d|[01]?dd?)"; //copied from internet and edited
String two = "((25[0–5]|2[0–4]d|[01]?dd?)(.)){3}(25[0–5]|2[0–4]d|[01]?dd?)"; // copied from book
String x = "((25[0-5]|2[0-4]d|[01]?dd?)(.))";
String y ="((25[0–5]|2[0–4]d|[01]?dd?)(.))";
[Code] ....
I'm trying to integrate google reverse geocoding address into my jsf application. I would like to be able to enter a postcode and hit a 'Find Address' button to bring me back all the addresses within that location. I have attempted the script below just to get something working in html then build a jsf2 page up. The results that I keep getting back are for a specific building rather than a list of houses within the same street. I think this is because I'm using the lat/long.
<!DOCTYPE html>
<html>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<body>
<div id="latlng" value="53.561922,-2.120010"></div>
[Code] ......
Facing problem with java.net.InetAddress class while validating special form of IPv6 address.
Please check the following piece of code.
String ipv6 = "0:0:0:0:0:ffff:a1f:e403";
try{
final Inet6Address i6 = (Inet6Address) InetAddress.getByName(ipv6);
System.out.println(i6);
}
catch(ClassCastException e){
System.out.println("Not a proper ip: "+e);
}
It is throwing ClassCastException.
I am doing an assignment for a college class. We are asked to get user input and decide if it is a valid IP address and then check what class the address is and if it is a public or private address.
So far, I can get the input, and check to see if the numbers are in a valid range. I can also display the IP address to the user. I am having an issue figuring out how to get the program to check the classes and whether they are public or private.
import javax.swing.JOptionPane;
/**
This program will take user input and calculate whether it is a valid IP address and the class that it belongs to.
*/
public class shortONE_1
{
public static void main(String[] args)
{
//Variables
final int MIN_OC = 1; //Minimum number accepted
final int MAX_OC = 255; //Maximum number accepted
final int MIN_A = 1; //Min number for class A
final int MAX_A = 127; //Max number for class A
[Code] ....
So for the last few weeks I have been working on a Java project for school. I see the light at the end of the tunnel, but I have run into some speed bumps with my main class. It was working fine, but I was pulling an all night and I deleted some of my code by mistake.Now I am not seeing what is exactly wrong. Anyways, the project was to create an address book complete with a menu system.
Here are all of my classes:
import java.util.ArrayList;
/**
* A model of an address book which keeps track of contacts.
* An address book object should keep track of the concept of a current contact (think index).
* You must use an ArrayList for your implementation.
*/
public class AddressBook {
Contact contact = new Contact();
[code]....
So far I only know using
request.getRemoteAddr() get
to get user IP address, is that a way to get Users PC memory?
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
Only get server memory not the client....
I need to track the client IP address from where user requested to my application.
I tried following:
request.getHeader("HTTP_X_FORWARDED_FOR"));
request.getHeader("X-Forwarded-For"));
request.getHeader("Proxy-Client-IP"));
request.getHeader("WL-Proxy-Client-IP"));
request.getHeader("HTTP_CLIENT_IP"));
request.getHeader("HTTP_X_FORWARDED_FOR"));
request.getRemoteAddr());
String ip = InetAddress.getLocalHost().getHostAddress();
In which InetAddress is giving my local machine IP when i run my application in localhost, but I mapped localhost:8080 with IIS server then InetAddress not giving exact IP address. How can we resolve this?
Applications: Netbeans (8.0.1), Apache Tomcat
My Aim: Creation of a telephone book
How should it work:
I have a Database with Data of people (name, adress, phone number).
If a user enters a phone number (CLIENT) -> the correct person with the name and adress should appear.
I build up the infrastructure and now I'm at the point that I have to create a Webmethod for it. I just worked on projects like addition of two integers, hello "name", ... I think this example now is harder, BUT i can learn a lot!
I have two Strings
String TO = "raj@gmail.com;ra@gmail.com;RS@yahoo.com";
String CC= "rajt@in.com;rht@basss.com";
My query is i want to extract domains from above two Strings and Store these domains in HashSet. How could i do this with minimum code and performance wise.
I want to get current Computer CPU usage of my computer and display it in Console View of Eclipse? How can I achieve this?
My template code is:
Java Code: public class GetCPUUsage{
public static void main(String[] args){
System.out.println("CPU USAGE IS: ??????");
}
} mh_sh_highlight_all('java');
I added ??? as placeholder for CPU usage because I do not know how to retrieve RAM usage by Java.
I know there are Java graphics classes, and how to use them to draw images in a window, but how do those classes interact with the screen to create the image? At the very base of it all, what is the code that is passing the computer the data to display on its screen? I'm asking because I've seen several ways to do Graphics/GUIS, a lot of them involve the Graphics class, but what is it inside all of that that that makes it work? Also, is everything else involving graphics (any other graphics libraries people write) pretty much "on top" of the Graphics class or is there something else within it more basic that is being used?
View Replies View Related