


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Java Basics - Part I
(lectures programs)
Sun OnLine Documentations
Chapter 2: Everything is an Object
First Example: HelloDate
Run as applet
public class HelloDate { public static void main(String[] args) { System.out.println("Hello, it's: "); System.out.println(new Date()); } }
% make OR % javac HelloDate.java
% java HelloDate
% javadoc HelloDate.java
(use netscape to look at the documentation HelloDate.html )
Exec Example: Exec
This excute any program, e.g.:
public class Exec { public static void main(String[] args) { try { String command = args[0];
System.out.println("exec: " + command);
Process p = Runtime.getRuntime().exec(command);
p.waitFor(); } catch (InterruptedException e){} catch (IOException e){} } }
Example: % jave Exec prog Where prog can be:
Note that prog.Who produces no output!
Chapter 3: Controlling Program Flow
Run as applet