Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Monday, July 30, 2012

Adding ANT SCP task support to Mac OS X

My ANT build script for a web application I’m working on is using the SCP task to use a secure shell copy from my local system to the remote server. After upgrading to Mac OS X 10.7 “Lion” and Mac OS X 10.8 “Mountain Lion” I lost my ability to use this task. I found this post comment by a member of the ANT team that pointed out that when Apple compiled the version of ANT in Mac OS X they didn’t include the optional JAR files needed for additional tasks. This means that, for me, the baked in version of ANT is missing ant-jsch.jar

To restore this functionality, first I opened a Terminal prompt (I use iTerm2, then determined the version of ANT installed on my version of Mac OS X by typing ant -version. On Mac OS X 10.8 “Mountain Lion” it reported that I was using Apache Ant(TM) version 1.8.2 compiled on June 20 2012.

Next I downloaded from the Apache ANT website the 1.8.2 binary distribution of ANT located at http://archive.apache.org/dist/ant/binaries/. After the download completed I extracted the archive and found the file ant-jsch.jar that I needed.

To determine the correct path to place this file, I executed ant -diagnostics | grep ant.home to find the path, which for me was ant.home: /usr/share/ant. I then copied the ant-jsch.jar file to the /usr/share/ant/lib directory.

I now needed the actual JSch JAR file that has the tasks. I was able to download the file jsch–0.1.48.jar from http://www.jcraft.com/jsch/index.html. I created a directory to store this in my root by using the mkdir -p ~/.ant/lib command and copying the jsch-0.1.48.jar file to that ~/.ant/lib location.

Now I’m able to use the scp task in my ANT build files, yea!

Without this I would continue to receive the message "Not Available (the implementation class is not present)"

Thursday, June 09, 2011

Installing Oracle Java on Ubuntu 10.04 LTS

It seems lately that I've installed Oracle Java on a number of Ubuntu systems, and while I have a small little "cheat sheet" on how I do it here, I thought putting it on the blog might be something useful for others. If nothing else I know where to look if I can't find it on my system here. This assumes you're running Ubuntu 10.04 LTS (I can't speak to other versions) and that you're using 1.6_26 (it's the current version as of this writing). Modify the file name accordingly if a newer version is available. This will install the java files into the /usr/local/java folder, create a link of /usr/local/java/latest that points to the latest version (makes it easy to change when you install a newer version of Java). Finally it sets up the environment variables and path on your system. Download the Java Development Kit
wget http://download.oracle.com/otn-pub/java/jdk/6u26-b03/jdk-6u26-linux-x64.bin
Make the file executable and then execute the self-extraction
sudo chmod +x jdk-6u25-linux-x64.bin
sudo ./jdk-6u25-linux-x64.bin
Now we remove the JDK to the /usr/local/java folder, remove the downloaded file and setup the environment variables and path
    sudo rm -rf jdk-6u26-linux-x64.bin
    sudo mkdir -p /usr/local/java
    sudo mv jdk1.6.0_26 /usr/local/java/jdk1.6.0_26
    sudo ln -s /usr/local/java/jdk1.6.0_26 /usr/local/java/latest
    sudo mv /etc/environment /etc/environment.bak
    sudo echo "JAVA_HOME=\"/usr/local/java/latest\"" > ~/environment
    sudo echo "JRE_HOME=\"/usr/local/java/latest/jre\"" >> ~/environment
    sudo echo "PATH=\"\$JAVA_HOME/bin:$PATH\"" | cat >> ~/environment
    sudo mv ~/environment /etc/environment
    sudo echo "export JAVA_HOME=\"/usr/local/java/latest\"" > /etc/profile.d/javaenv.sh
    sudo echo "export JRE_HOME=\"/usr/local/java/latest/jre\"" >> /etc/profile.d/javaenv.sh
    sudo echo "export PATH=\"\$JAVA_HOME/bin:$PATH\"" | cat >> /etc/profile.d/javaenv.sh
    sudo /etc/profile.d/javaenv.sh
Confirm Java is installed and the version is correct
java -version

Thursday, May 19, 2011

Optimizing Eclipse for Mac OS X

This section will outline a few options that can increase the performance of running Eclipse on the Mac OS X platform. To do this you need to modify the eclipse.ini file. by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini in the MacOS folder under Contents.

  • Open the Finder Locate the Eclipse program 
  • Right-click on the Eclipse program, select “Show Package Contents” 
  • Open the Contents folder 
  • Open the MacOS folder 
  • Open the eclipse.ini file with TextEdit
  • Change the file contents to add/update the following: 
-showsplash org.eclipse.platform 
--launcher.XXMaxPermSize 256m 
-vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java 
-vmargs 
-Xms128m 
-Xmx512m

It’s important to note a few things.  The “-vm” argument must be on it’s own line.  After that you can specify your Java virtual machine to make sure you’re using the latest version.  This probably isn’t a big deal on the Mac platform, since there’s usually only one provided by Apple, but on a Windows system you may have a plethora of Java installs.

Also the “-vmargs” must come AFTER you specify the version of Java to use.  After this you can specify the memory settings for the JVM.  I’m setting the default memory allocation for Eclipse to be 128MB and the maximum to be 512MB.   You can adjust yours accordingly.