This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes How I connect to remote Unix Box from standalone java application? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How I connect to remote Unix Box from standalone java application?" Watch "How I connect to remote Unix Box from standalone java application?" New topic
Author

How I connect to remote Unix Box from standalone java application?

Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Hi All,
Can anybody help me regarding the Unix box connection:
I am going to write a standalone java swing application, here I planned to provide all the unix box details like-IP address/host name, user id and password. I need to read some files from the remote unix server and want to write it to the local machine. All this things I need in Windows platform.

Can anybody give me any idea, how I will connect to unix box from java?

I am waiting for the reply.


Regards, Rudra Narayan
www.garnaik.com
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8260

The server must provide some service (FTP, HTTP, custom server, network share) that your application can connect to. Once you determine what is available on the server, you know what you need on the client side to connect.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Access is given to me and I able to access that unix box, but how I connect to it from my java application? I need some sample java codes which will connect to my remote server(Unix box).

Please can anybody will help on this....
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8260

How do you access it? SSH? Telnet?
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
I am accessing my unix box through telnet.

I want to connect to it by giving the userid, password and host ip altogether.
Just look into the below command line:

telnet ://userid assword@host-ip

I am calling this line from java program.
But I unable to connect, it is giving the error:

Connecting To ://uid ass@hostip...Could not open connection to the host, on port 23: Connect failed.

Can anybody suggest me on this?

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8260

Originally posted by Rudra Narayan Garnaik:
I am accessing my unix box through telnet.


Great. Unfortunately, telnet doesn't have a file transfer capability, whereas SSH does. How about contacting your Unix admin, telling them what you have in mind and seeing what file transfer protocols they support?


I am calling this line from java program.
But I unable to connect, it is giving the error:


Again, you need to Tell The Details. There are many ways to "connect" to a remote server, each with it's own pitfalls. Without knowing the details of what you are doing, we can't help.
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Guys finally I got the solution for this issue:
Ist download the plink.exe from google search.
set the classpath for that.
The details are written as below:
------------------------------------------------
set CLASSPATH=%CLASSPATH%;lib\plink.exe;
plink -ssh -l userid -pw password -P 22 hostname
------------------------------------------------

If you unable to get the plink.exe then write to me so that i will help.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How I connect to remote Unix Box from standalone java application?
 
Similar Threads
Standalone Java Client for WebSphere default Messaging.
If I wanted to connect and read files from remote unix box using java application
Java Swing Application that connects to UNIX box and execute some UNIX commands
Connecting to Unix via Windows
Using MQ Client