To extract a file from a jar, like to see if it's executable, do:
jar xvf /Users/siemsen/.m2/repository/edu/ucar/TranslateCIM/1.0-SNAPSHOT/TranslateCIM-1.0-SNAPSHOT.jar META-INF/MANIFEST.MF
Then look in the resulting META-INF/MANIFEST.MF file. If there's a Main-Class header, the jar is executable.
I downloaded JavaSE6 from the Apple website - it was released about 10 days ago. After I did, I ran the Java Preferences application and changed the "Java Version" from J2SE 5.0 to Java SE 6 and the "Java Application Runtime Settings" to Java SE 6 (64-bit). Then I did
okapi$ javac -version
javac 1.6.0_05
okapi$
Note that Java Preferences shows that Safari will still use Java 5 for applets, because Safari is still 32-bit and can't use a 64-bit plugin. But Safari will use Java 6 for Java Webstart applications.
2008-04-07
To install Java 6 on Ubuntu, I did
sudo aptitude install sun-java6-jdk sun-java6-javadb glassfish netbeans5.5
You can get either the Sun distribution of Java or the Blackdown distribution. The Sun version usually installs in /usr/java. The Blackdown version usually installs in /usr/local. So you can have both on your system at once.
Google-search for "blackdown" and get j2sdk-1.4.2-rc1-linux-i586-gcc2.95.bin. Put in in /usr/src and do
as root
chmod +x j2sdk-1.4.2-rc1-linux-i586-gcc2.95.bin
rm j2sdk-1.4.2-rc1-linux-i586-gcc2.95.bin
chown -R root j2sdk1.4.2
chgrp -R datacomm j2sdk1.4.2
Sun wants you to click "ACCEPT" on a license form when you download Java. Raw "ftp" doesn't provide a way to make this happen, so Sun does not provide FTP downloads of Java. You have to get it through the web.
Web to Sun's JAVA home page and follow links to get the JAVA SDK. You'll need the RPM version, because when you try to install OpenNMS later, it will check dependencies. As of 2005-05-02, I got jdk-1_5_0_03-linux-i586-rpm.bin.
(as root)
sh jdk-1_5_0_03-linux-i586-rpm.bin
rm jdk-1_5_0_03-linux-i586-rpm.bin jdk-1_5_0_03-linux-i586.rpm
The Java JDK is now installed in
/usr/java/jdk1.5.0_03. See the
file:///usr/java/jdk1.5.0_03/README.html
for a description of what's in the JDK.
I added this to my .bashrc file.
Note that OpenNMS wants JAVA_HOME to be set.
export JAVA_HOME=/usr/java/jdk1.5.0_03
pathadd ${JAVA_HOME}/bin
The info about how to load the 1.4 plugin for Netscape/Mozilla, see my Netscape page. To see what plugin you're running, do Help->About plugsins or web to http://www.psc.edu/~jheffner/misc/JavaVersion.html
The Java Tutorial explains how to compile and run a Hello World program and a Hello World applet. I made both of these work.
You want to do this so you can do Java development offline.
I downloaded the jdk-6-doc.zip file from the Sun website. I unzip'd it, creating a directory named "docs". I saved it in /usr/web/java/docs. I didn't save it under my own web because I don't want to accidentally copy it to netserver. Then I could reach it at http://127.0.0.1/java/docs/.
One of the most confusing things about Java is the CLASSPATH, packages, and import statements. Here are some notes:
When you run a JAVA program, you may get several messages like
Font specified in font.properties not found [xxx]
This refers to the $JAVA_HOME/jre/lib/font.properties file. I searched the web and found http://java.sun.com/j2se/1.3/install-linux-sdk.html#problems: which had a link to a newer version of the file. I installed the newer file and the problem vanished. I suspect that the problem won't exist in JDK 1.4.
The "Thinking in Java" book is good. So is "Effective Java".
When coding a method, if a given argument is not modified in the body of the method, declare it "final" in the argument list, to tell the reader and the compiler.
Log4perl and log4j provide a de-facto standard way to output messages from Perl and Java programs. I use them in my own standard way to provide a logging framework that meets almost all of my needs. My standard way to use them is described in my Logging page.
I loaded it onto npad, and did
cd /usr/src/findbugs-0.9.4
cp -R /usr/src/findbugs-0.9.4/doc /usr/web/findbugs
...after which I could web to http://npad.ucar.edu/findbugs/.
I edited the .bashrc file to add /usr/src/findbugs/0.9.4/bin to my PATH. I started it by just saying "findbugs". I did File->New Project. For the Archive or Directory I browsed to /home/siemsen/npad/java. I clicked "Find Bugs!". It produced an "Analysis Errors" window showing lots of Java classes that it couldn't find. Ignore that window by clicking "OK", and you get cool lint-like errors.
See Viewing a browser's Java Console.
ยก