Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: connect to linux server from windows

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default connect to linux server from windows

    hi

    i'm trying to connect to linux server via eclipse,
    i want to run tests on the linux server (like send wget requests).
    usually i'm using putty to make this tests, but i want to write java program to make these tests.
    but the problem i have no idea how to connect to the server and how to send wget requests.
    please advise.
    thanks,


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: connect to linux server from windows

    Quote Originally Posted by ridg18 View Post
    hi

    i'm trying to connect to linux server via eclipse,
    i want to run tests on the linux server (like send wget requests).
    usually i'm using putty to make this tests, but i want to write java program to make these tests.
    but the problem i have no idea how to connect to the server and how to send wget requests.
    please advise.
    thanks,
    ridg18
    sure you can do that in Java. Remember that Java is OS-independent. That's the reason why Java survive so well You can have a Server on Window and Client on Linux (or ubuntu) and vice versa. There're enough examples Server/Client in this forum. For example my codes for souparno http://www.javaprogrammingforums.com...ce-server.html

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: connect to linux server from windows

    thanks Voodoo,

    i know how to use socket,
    but how i can send get and posts requests??

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: connect to linux server from windows

    ridg18
    uh oh...you talk about a totally different issue. POST or GET is the keywords of HTTP (HyperText Transfer Protocol) and has nothing to do with Java. Your Server and your Client can run any protocol. It depends fully on your server/client implementation if they "understand" HTTP or other protocol, for example, SOCKSx (x = 4/5). Normally every Browserserver (port 80) understands HTTP. Hence, your Browser field always stands Http://...
    Here is an example to show you how to "read" GET/POST/CONNECT/etc.
    ...
            Socket s = new Socket(host, 80);  // to a Browserserver.
            ....
            InputStream in = s.getInputStream(); 
            StringBuffer buf = new StringBuffer();
     
    	while ((b = in.read()) != -1) {
    		buf.append((char)b);
                    if (buf.indexOf("\r\n\r\n") > 0) break;
    	}
            String header = buf.toString( );
            if (header.toUpperCase().indexOf("GET ") == 0) { // GET command }
            else if (header.toUpperCase().indexOf("POST ") == 0) { // POST command }
            ...

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: connect to linux server from windows

    ok
    i think i didnt explain my problem,
    im working with eclipse in windows, and i have application that i should test that works in linux server.
    usually i use the winscp and open putty and i send this wget from putty
    (wget "http://localhost:7014/callme.groovy?amsisdn=12420000001&bmsisdn=12423310 050&lang=01")

    i want to run the tests from eclipse,
    thats mean connect to the linux server from eclipse and run the wget request.

    how i can run this test?

  6. #6
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: connect to linux server from windows

    Sorry, buddy.
    I don't use eclipse or any IDE so I can't tell you anything about how to do it with eclipse. The Socket way demands more knowledge about network and diff. web protocols (HTTP, SOCKS, XML, etc.). The easiest way is to use URL, URLConnection and HttpURLConnection. However, it requires you a good knowledge of HTTP, too.

  7. #7
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: connect to linux server from windows

    Hi ,

    You can use ganymed-ssh2-build.jar to connect to linux from java code.Use this link - ch.ethz.ssh2

Similar Threads

  1. XMLBeans - how to control generated class files? windows vs linux issues
    By g20zoom in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 6th, 2012, 12:01 PM
  2. Replies: 1
    Last Post: June 7th, 2011, 11:53 AM
  3. KeyStore.getInstance("Windows-MY") : Equivalent on Linux plateform ?
    By Nicolas74100 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 14th, 2010, 03:49 PM
  4. Under Windows OS, how to call *.EXE produced in Linux OS?
    By tony_lincoln in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 19th, 2010, 12:51 AM
  5. getting files in the linux server
    By Truffy in forum Java Networking
    Replies: 36
    Last Post: June 22nd, 2009, 06:32 PM