Posted by walrus on July 21, 2008
Here is how to setup JAVA_HOME and PATH environment variables for a single user or all users on Fedora Linux system
Setting JAVA_HOME and PATH for a single user
# vi ~/.bash_profile
# export JAVA_HOME=/opt/jdkx.x.x_xx
# export PATH=$PATH:$JAVA_HOME/bin
Setting JAVA_HOME and PATH for all users
# vi /etc/profile
# export JAVA_HOME=/opt/jdkx.x.x_xx
# export PATH=$PATH:$JAVA_HOME/bin
Posted in Software, Technology, java, linux | Tagged: java, linux, shell | Leave a Comment »
Posted by walrus on July 17, 2008
The following sample code works well with Java 1.5 and Apache Commons Net 1.4.1
import org.apache.commons.net.ftp.*;
...
boolean ftpTransfer(String localfile, String destinationfile)
{
String server = "ftp.domain.com";
String username = "ftpuser";
String password = "ftppass";
try
{
FTPClient ftp = new FTPClient();
ftp.connect(server);
if(!ftp.login(username, password))
{
ftp.logout();
return false;
}
int reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
return false;
}
InputStream in = new FileInputStream(localfile);
ftp.setFileType(ftp.BINARY_FILE_TYPE);
boolean Store = ftp.storeFile(destinationfile, in);
in.close();
ftp.logout();
ftp.disconnect();
}
catch (Exception ex)
{
ex.printStackTrace();
return false;
}
return true;
}
Posted in Apache, Software, Technology, java | Tagged: apache commons, code, ftp, java | Leave a Comment »
Posted by walrus on July 3, 2008
A step towards making TextPad a lightweight IDE. Using the trick below, you can compile your code using Ant from inside TextPad. Click on the error messages and jump to the source file and the problematic line of code.
- First, make sure you can compile from the command line using Ant
- In Textpad, go to Configure-> Preferences-Tools.
- Click on the Add button and select the Dos Command option
- Enter ant -find in the edit box and press OK to dismiss the dialog box.
- Now press the Apply button
- In the left pane, expand Tools and highlight ant -find
- In the right pane, select capture output and save all documents first options
- Enter the following Reguar Expression ^[ \t]+\[javac\] \([A-Za-z]:[^:]+\):\([0-9]+\):
- Set File to 1 and Register to 2
All done. To run Ant, select it from the “Tools” menu. The build.xml file should be in the same directory, or in any ancestor directory.
Posted in Apache, Software, Technology, Windows, java | Tagged: ant, build, code, Software, Technology, text editor, textpad | 1 Comment »