Re: Help a newbie please?
On 2009-04-08 20:53:35 -0400, SpreadTooThin <bjobrien62@gmail.com> said:
On Apr 8, 2:05?pm, SpreadTooThin <bjobrie...@gmail.com> wrote:
?haven't written a line of java in years... but today I have to write
a script. (On a MAC in XCode)
So I found this on the internet:
http://stackoverflow.com/questions/14617/java-what-is-the-best-way-to...
Nice simple method
I downloaded j2ssh which has a few jar files in them.
Obviously this won't compile / run unless the right jar file is in the
right place.
j2ss contains:
j2ssj-ant-0.2.9.jar
j2ssh-common-0.2.9.jar
j2ssh-core-0.2.9.jar
j2ssh-daemon-0.2.9.jar
and lib:
BOUNCYCASTLE.LICENSE
COMMONS.LICENSE
XERCES.LICENSE
commons-logging.jar
jdk13-119.jar
xercesImpl.jar
xmlParserAPIs.jar
So where do I put these files so that my app will compile / run?
TIA
Ok I've figured out what is going on.. Sort of.. At least I can make
my application now, but Its not running.
I had to copy the jar files to /System/Library/Java/Extensions.
This will also break other Java programs: libraries in
/System/Library/Java/Extensions (or lib/ext on other platforms :) are
visible to every single Java program run by that VM, including programs
that may be expecting a different version of those libraries.
Use the -classpath command-line and Class-Path: manifest tools. Don't
use the extensions dir or a global CLASSPATH environment variable.
Local changes are much easier to deal with than global changes to your
system.
You asked elsewhere in this thread how to find out what classes and
methods are in a librarly. A little googling suggests that the "j2ssh"
JARs are from the SSHTools project, whose website is
<http://sshtools.sourceforge.net/>. Normally, a project's website also
has documentation; sshtools seems to have failed at this as their
website is nearly empty. You can also get a list of files in a JAR:
$ jar tf commons-logging-1.1.1.jar
[...]
org/apache/commons/logging/impl/Jdk14Logger.class
org/apache/commons/logging/impl/Log4JLogger.class
[...]
Each .class file corresponds to a Java class, so this JAR contains
org.apache.commons.logging.impl.Jdk14Logger,
org.apache.commons.logging.impl.Log4JLogger, and so on.
Unfortunately, this tells you nothing about how to use the library;
it's merely a giant list of every class it contains, including ones you
can't (or shouldn't) use directly. Fortunately, SSHTools' Sourceforge
download page has both documentation and tutorials:
<http://sourceforge.net/project/showfiles.php?group_id=60894>
It sounds like you're using Ant to build your project, so you should
probably have a look at the Ant manual pages for the 'javac'
(http://ant.apache.org/manual/CoreTasks/javac.html) and 'java'
(http://ant.apache.org/manual/CoreTasks/java.html) tasks. If you're
planning on using your program outside of Ant in the future, you'll
want to look at the 'jar'
(http://ant.apache.org/manual/CoreTasks/jar.html) task for packaging
your own code. Distribute both your own JAR and the JARs you depend on;
don't re-package your libraries into your JAR.
HTH
-o