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: Java and ssh questions from a newbie

  1. #1
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java and ssh questions from a newbie

    Respected Java coders,
    Pardon my "noob" ness when I ask the question.
    I had done Perl Scripting earlier, where using Perl modules, the script would login to various storage devices, run a few commands, gather the outputs, filter out the unrequired sections, and email the output for monitoring alerting.
    If the script was to be run from another server, not only would it require Perl installed, but the other modules also would be required to be installed, which at times was not allowed due to security reasons.

    Java also has a similar concept of libraries / modules such as jcabi-ssh, sshj etc which allow ssh connections.

    So now suppose I write a code that does something similar as what I was doing earlier with Perl, and then save it as say my_monitoring_code.java and then:

    1) Run the
    javac my_monitoring_code.java
    command which will create a file
    my_monitoring_code.class
    and then
    2) Load my_monitoring_code.class file on another server that has Java installed and try to run it from there
    will it work? Or do I have to install the libraries / modules on the other server as well?

    Kindly let me know.

    I once again apologize if my question sounds half baked/confusing/newbie like, but would be thankful if someone could answer.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java and ssh questions from a newbie

    Load my_monitoring_code.class file on another server that has Java installed and try to run it from there
    The class file should execute if the javac and java programs are at the same version level or if the java program is younger than the javac program.

    Normally class files are bundled into a jar file with a manifest file so they can be executed by "opening" the jar file by clicking on it. The jar file can then be copied to other computers with compatible java commands.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java and ssh questions from a newbie

    Hi Norm,

    Thank you for the answer.

    Just for clarity, if I have the same exact version of javac and java (or younger) on the other computer, or, if I bundle it in a jar file , I don't need to install the ssh modules on the other server?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java and ssh questions from a newbie

    Sorry, I don't know what ssh modules are.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java and ssh questions from a newbie

    Quote Originally Posted by Norm View Post
    Sorry, I don't know what ssh modules are.
    Hi, apologies for using incorrect terminology.

    I was talking about the Java libraries such as jcabi-ssh, sshj etc which allow ssh connections.

    So my question actually was, if I have the same exact version of javac and java (or younger) on the other computer, or, if I bundle it in a jar file , I don't need to install jcabi-ssh, sshj on the other server?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java and ssh questions from a newbie

    If a java program uses a class file, that class file needs to be accessible to it when it is executed.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Java and ssh questions from a newbie

    In case you haven't seen it, check out Oracle's Packaging Programs in JAR Files tutorial. The links "Working with Manifest Files: The Basics" -> "Adding Classes to the JAR File's Classpath" are also relevant here as they explain how the sshj or other jars can be referenced from your application's jar file.

    It might pay to start with a rather limited version of your program and play around with the process of deploying it to another computer as described in Oracle's tutorial. This might save disappointment later, and, if problems occur, you'll have something specific to ask about. It's never easy to come to grips with the nuts and bolts of a new language environment and when you throw 3rd party encryption, logging etc and build tools like gradle into the mix it's very easy to get lost. Good luck!

Similar Threads

  1. how to create ssh server
    By bean in forum Java Servlet
    Replies: 5
    Last Post: October 7th, 2017, 01:55 AM
  2. ssh server throwing exception
    By bean in forum Java Networking
    Replies: 3
    Last Post: October 4th, 2014, 12:56 PM
  3. SSH session with server
    By Paris in forum Java Networking
    Replies: 11
    Last Post: January 21st, 2013, 06:35 AM
  4. [SOLVED] SSH
    By rachana in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 3rd, 2011, 09:01 AM
  5. Newbie questions about lesson on class implementation
    By Jonnybravo9 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 7th, 2010, 09:04 PM