Java Reference
In-Depth Information
Create an ErrorMsg class:
1. Using a text editor, create a Java source file named ErrorMsg.java in the
java4cobol directory. The source file should contain these statements:
public class ErrorMsg {
// Define some public class instance variables.
public String msgText = " ";
public int msgSize;
// Define a public method.
public void setErrorMsg (String inputMsg) {
// Modify one of the public variables. Set this variable to the text
// String that was passed as a parameter.
msgText = inputMsg;
// Return from this method. Since this method has no return value (i.e.,
// it is declared as void), no return statement is necessary.
}
// Define another public method.
public String getErrorMsg () {
String returnMsg;
// Set the local variable returnMsg to the data member msgText.
returnMsg = msgText;
// Return from this method, and return this String variable.
return (returnMsg);
}
}
Remember to save this source as a text file instead of a document file. The
file name should be c:\java4cobol\ErrorMsg.java.
2. In the DOS command window, change the current directory to your
java4cobol directory:
cd c:\java4cobol
3.
Compile your class, using the javac compiler:
javac ErrorMsg.java
Again, your class should compile successfully at this point. If it doesn't,
review the suggestions mentioned in the introductory SDK exercises.
Search WWH ::




Custom Search