Programming / Subversion / Databases
Programming in Linux
Java
For java programming, you will need to make sure that the java executable files are in your PATH, and that your java CLASSPATH is set up correctly. You can set up these environment variables by editing the file .bash_profile in your home directory, or you can copy the profile file /etc/skel/.bash_profile into your own home directory. This will set the environment variables correctly each time you log in.
The command javac compiles a java source file, java runs a java class file.
(e.g. javac file1.java will produce file1.class, while java file1 will run the file).
The above profile file includes in the CLASSPATH servlet.jar for compiling servlets.
Servlet Class Files and JSP files
* Your home directory should contain a public_html/WEB-INF/classes directory, and put your class files in this directory (e.g. your class files will be located in /home/cs2000/s02bf000/public_html/WEB-INF/classes). To do this, type
javac -d ~/public_html/WEB-INF/classes file1.java.
These files will be available via a browser at
http://csserver.ucd.ie:8080/~s02bf000/servlet/file1
It is advisable not to manually remove or change any files in the classes directory.
* To access Java Server Pages, put your jsp files in your public_html directory, so that they are then available via a browser at
http://csserver.ucd.ie:8080/~s02bf000/filename.jsp
Any class files that these jsp files use must be located in the classes directory above.
* To access your mysql database from a servlet:
Type env to check your CLASSPATH. Your CLASSPATH should look like
CLASSPATH=:/usr/local/tomcat/common/lib/mysql-connector-java.jar:.
Your java source file should contain
...
import java.sql.* ;
...
String driver = "com.mysql.jdbc.Driver" ;
String url = "jdbc:mysql://localhost/database_name" ;
String username = "your_username" ;
String password = "your_password" ;
...
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, username, password);
Subversion
Subversion is available on Csserver. Here is a guide to the basic command-line usage.
Database Accounts
mysql database accounts are available for 3rd year and final year Computer Science students. To obtain an account contact your course tutor or demonstrator, or csproblems.
To use mysql type
mysql -h csserver.ucd.ie –p
and enter the password when prompted. This can be done either from csserver.ucd.ie (in a ssh session) or from the PCs in the lab when you boot into Linux.
You will be able to create a database which has the same name as your login id (e.g.
"CREATE DATABASE s02bf000;")
on which you will have full access.
The mysql software and documentation is available at http://www.mysql.com



