Hello all,
I'm very new to
Java and am self-teaching myself the language. By trade, I specialize in Unix/Linux administration, so have been coding for years, primarily in shell, then, Perl, then PHP, and finally Python. However, I'd like to get more involved in application development and I am now with a small company who is using Java as the primary development language. So, I figured, time to learn it. Thus far all has gone well, but I have some questions that hopefully someone can help me with:
1) To start things off, I am attempting to rewrite a Python process that I have into Java. The process connects to a databases, extracts a list of hosts, and the uses SSH to connect to those hosts, retrieve system information, and update the DB. I find it easier to learn a new language if I take an existing piece of my own code and rewrite it. So, thus far I have the DB connection piece working fine after reading some tutorials on
JDBC. I created a "DatabaseConnection" class that I call from the main method, passing it a SQL query via a runQuery() method. It uses JDBC to open a connection to a postgreSQL database, do its stuff, close everything up, and return the result. All works well, and I'm fairly happy with how much I learned getting this up and running. The second step though is to open an SSH session to a remote host and run commands. So, I found JSch for this. Everything made sense until I instantiated a Channel object , and then... chaos. The next line in the tutorial does something like "((ChannelExec)channel).setCommand(cmd)" and I am lost as to what the ((ChannelExec)channel) actually means in the Java language. Is that a short hand for executing a method? I also noticed that, further down in the example, it gets increasingly low level. In the Python world, I use Paramiko extensively for SSH connectivity. Is there a library in Java that is a bit more high level? This sort of brings me to the second question.
2) Where do I find the popular, and active libraries? With Python, I go to pypi.python.org, with Perl I would go to CPAN, with PHP, PEAR. Is there an equivalent for Java? I can google "Java SSH libraries" and find quite a few, but there is no simple way of determining which ones are popular or maintained other than digging into each site. Not a big deal, I'm not that lazy, but I just wonder if there is an easier site/repository out there that I'm missing out on.
3) Last question (promise). GUI design. I've been playing around a bit with
JSP and
servlets using the Murach book (love these books). I'm aware that JSP/Servlets with a basic
Tomcat server and no framework may be dated, but I want to learn the basics before moving on to something else. In addition, there is legacy code out there written like this, and I want to understand it. I'm okay with web development for the most part, having used a variety of frameworks (Django, web2py), and bare bones Perl/CGI, PHP in the past. What I'm interested in here is actual GUI design, i.e. using Swing. Is it possible to write a desktop application in Swing, and then deploy it over Java Web Start or would I be better off just focusing solely on web application development these days. I ask because the users would be a small group, all with very good network connectivity to the internal network. So, deploying something this way would give me a real GUI environment and teach me Java.
That's it. So far, I'm really enjoying learning the language. It is much different from anything I've used before. It seems like it "forces you" to code correctly. I.e. OO is not optional, and I see things like it generating an error if I forget to wrap a method in a try/catch block with an exception. As my day job is spent doing more systems engineering/administration, and less coding I'm sort of relegated to learning this during off hours so don't always get a chance to delve too deep. So, any basic beginner advice is appreciated.
Best Regards,
Tom