• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get router status (up or down) in java ?  RSS feed

 
uniojn qoifazy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
is it possible to to get router status (up or down) in java ?
Can anyone give some examples of this ?



I would greatly appreciate it if you kindly give me some feedback on this
 
Henry Wong
author
Sheriff
Posts: 22853
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uniojn qoifazy wrote:hi all,
is it possible to to get router status (up or down) in java ?
Can anyone give some examples of this ?

I would greatly appreciate it if you kindly give me some feedback on this



The router can be treated as just another machine on the network -- albeit, it is doing routing. This means it has an IP address, and in many cases, you can even hit an URL on it to get information. Where the router is depends on how it is configured, and how to get information on it, depends on what type of router it is, how is it configured, passwords, etc.

You need to contact your system administrator to get this information. Once you figure out how to do it manually, then you can teach your Java program how to do it programmatically.

Henry
 
uniojn qoifazy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i tried to connect my router and tried to run the sample code:





I got this error in the console -
HttpClient cannot be resolved to a type
GetMethod cannot be resolved to a type
UsernamePasswordCredentials cannot be resolved to a type

Any ideas what I'm doing wrong?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uniojn qoifazy wrote:Any ideas what I'm doing wrong?

You haven't included the Apache HttpClient jar file in your classpath.
 
uniojn qoifazy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have import org.apache.http.client.HttpClient;
isn't it ?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uniojn qoifazy wrote:i have import org.apache.http.client.HttpClient;
isn't it ?

Yes, but those classes are not part of the standard API, so you need to tell the compiler where it can find them.
You do this by including the appropriate jar files in your classpath.
 
uniojn qoifazy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now , i import commons-httpclient.jar

but still get 5 error msg as follow,

Cannot instantiate the type HttpClient
DefaultHttpMethodRetryHandler cannot be resolved to a type
HttpMethodParams cannot be resolved to a variable
The method executeMethod(GetMethod) is undefined for the type HttpClient
The method getParams() is undefined for the type GetMethod


I would greatly appreciate it if you kindly give me some feedback on this
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpClient is an interface - you can't create an instance of it. You need to create an instance of a class that implements it.

All the other classes appear to be members of the old standalone HttpClient class (V3.x) which is now discontinued.
You should be writing code for the new HttpClient (V4.3) which is part of the Apache HttpComponent project.

It appears this is not backwards compatible.


Edit: just noticed HttpClient was a class in V3.x - it's now an interface in V4.3.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!