Results 1 to 5 of 5
  1. #1
    rannie04 is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default Java Program Error: AS400 cannot be resolved or is not a type

    Good morning to all,

    I am Rannie, a Java newbie. I have encountered the errors below.
    Should someone have encountered the same problem before,
    kindly fill me in with what's the cause of the error and the applied solution to the problem. Would greatly appreciate your help.
    Provided below is the whole coding as well as the erroneous part.
    This Java program is supposed to be converting AS400 Spool File to a PDF.

    /*
    * Created on July 05, 2010
    *
    * To change the template for this generated file go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    */
    package com.myutils;
    import java.io.*;
    /**
    * @author rannie
    *
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    */
    public class SPLFtoPDF {
    public static void main(String[] args) {
    // Code Sample 1
    // Create program use text
    String pgmUsageText = "Use: SPLFToPDF iSeriesName cnnectingUser connectingUserPassword splfNam \n " +
    "splfNumber splfJobName SpoolfilejobUser spoolfileJobNumber pdfLocation";
    System.out.println("args.length"+args.length);
    if(args.length<9){
    // not enough arguments, exit
    System.out.println(pgmUsageText);
    return;
    }
    // We have enough arguments, read them and assign to temporary variables
    // Read the input arguments
    String systemName = args[0];
    String systemUserID = args[1];
    String systemPwd = args[2];
    String splfName = args[3];
    String splfNumberString = args[4];
    int splfNumber = 0;
    if(splfNumberString!=null){
    splfNumber = Integer.parseInt(splfNumberString, 10);
    }
    String splfJobName = args[5];
    String splfJobUser = args[6];
    String splfJobNumber = args[7];
    String pdfFile = args[8];
    // make sure the pdf file location is valid
    FileOutputStream fs;
    try {
    fs = new FileOutputStream(pdfFile);
    } catch (FileNotFoundException e1) {
    System.err.println("PDF file location is not valid. Please make sure you provide a proper Location");
    e1.printStackTrace();
    return;
    }
    //} //Note - original coding includes }
    //} //Note - original coding includes }
    // Code Sample 2
    // Establish a connection to the iSeries
    AS400 iSeriesServer = new AS400(systemName);
    try {
    iSeriesServer.setUserId(systemUserID);
    iSeriesServer.setPassword(systemPwd);
    iSeriesServer.setGuiAvailable(false);
    } catch (PropertyVetoException e1) {
    System.out.println("not valid system name or user id or password");
    e1.printStackTrace();
    // no valid connection to the iSeries server, so cannot proceed
    return;
    }
    try{
    /************************************************** ******
    * create the spooled file object using the input parameters
    ************************************************** ****/
    SpooledFile splf =null;
    splf = new SpooledFile( sys, // AS400
    splfName, // splf name
    splfNumber, // splf number
    splfJobName, // job name
    splfJobUser, // job user
    splfJobNumber ); // job number
    } //added by Rannie 08 July
    catch (Exception e) { //added by Rannie 08 July
    System.out.println(e.getMessage()); //added by Rannie 08 July
    } //added by Rannie 08 July
    //Code Sample 3
    //Read the spooled file attributes for determining if it is AFPDS or SCS type spool file
    if((splf.getStringAttribute(PrintObject.ATTR_PRTDE VTYPE)!=null)&&
    (splf.getStringAttribute(PrintObject.ATTR_PRTDEVTY PE).equals("*AFPDS"))){
    // handle AFPDS conversion to PDF
    convertAFPDStoPDF(splf);
    }
    else if((splf.getStringAttribute(PrintObject.ATTR_PRTDE VTYPE)!=null)&&
    (splf.getStringAttribute(PrintObject.ATTR_PRTDEVTY PE).equals("*SCS"))){
    // handle SCS spool file conversion to PDF
    convertSCStoPDF(splf);
    }
    //Code Sample 4
    PrintParameterList prtParm = new PrintParameterList();
    prtParm.setParameter(PrintObject.ATTR_MFGTYPE,"*WS CST" );
    prtParm.setParameter(PrintObject.ATTR_WORKSTATION_ CUST_OBJECT,
    "/QSYS.LIB/QWPDEFAULT.WSCST");
    PrintObjectTransformedInputStream inpStream =null;
    inpStream = splf.getTransformedInputStream(prtParm);

    // Code Sample 5
    // Read the input stream buffer and create a string buffer
    byte[] buf = new byte[32767];
    StringBuffer buffer = new StringBuffer();
    int bytesRead = 0;
    do {
    bytesRead = inpStream.read( buf );
    System.out.println(bytesRead);
    if (bytesRead > 0) {
    buffer.append(new String(buf,0,bytesRead));
    }
    } while ( bytesRead != -1 );
    // Code Sample 6
    // Create the document object for the PDF by setting zero margins
    float leftMargin =4f;
    float rightMargin =4f;
    float topMargin =4;
    float bottomMargin =4;
    try {
    Document document=new Document(PageSize.LETTER,leftMargin,rightMargin, topMargin, bottomMargin);
    try {
    PdfWriter.getInstance(document,fs );
    }catch (DocumentException e1) {
    System.err.println("document error happened. Unable to continue");
    e1.printStackTrace();
    return;
    }
    }catch (DocumentException e1) {
    System.err.println("document error happened. Unable to continue");
    e1.printStackTrace();
    return;
    }


    //}



    //Code Sample 7
    document.open();
    try {
    Font courierFont = FontFactory.getFont(FontFactory.COURIER, 8);
    Paragraph para = new Paragraph( buffer.toString(), courierFont);
    document.add(para);
    } catch (DocumentException e) {
    e.printStackTrace();
    }
    document.close();
    //finally{
    //}
    //Code Sample 8
    PrintParameterList prtParm = new PrintParameterList();
    prtParm.setParameter(PrintObject.ATTR_MFGTYPE,"*WS CST" );
    prtParm.setParameter(PrintObject.ATTR_WORKSTATION_ CUST_OBJECT,
    "/QSYS.LIB/QWPGIF.WSCST");
    PrintObjectTransformedInputStream inpStream =null;
    inpStream = splf.getTransformedInputStream
    (prtParm);
    //Code Sample 9
    byte[] imagebuff = null;
    try {
    imagebuff = new byte[inpStream.available()];
    inpStream.read (imagebuff );
    Image gifImage = Image.getInstance(imagebuff);
    document.open();
    document.add(gifImage);
    document.close();
    } catch (IOException e1) {
    e1.printStackTrace();
    } catch (DocumentException e) {
    e.printStackTrace();
    }
    //finally{
    //}
    }//Added by Rannie
    }//Added by Rannie




    Erroneous portion:
    // Code Sample 2
    // Establish a connection to the iSeries
    AS400 iSeriesServer = new AS400(systemName);
    Error:
    AS400 cannot be resolved or is not a type

    Erroneous portion:
    catch (PropertyVetoException e1) {
    Error:
    PropertyVetoException cannot be resolved or is not a type

    Thanks and Best regards,
    Rannie

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Where is the class AS400 defined? You need an import statement for it and a jar file that contains the class file.

  3. #3
    rannie04 is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi Norm,

    Thank you for the quick reply.

    I have downloaded the jar files that I believe contains AS400 class and put it in the
    Java Build Path --> Libraries --> jt400.jar.

    The jt400.jar has subdirectories com.ibm.as400.access --> AS400.class

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,791
    Rep Power
    19

    Default

    Yes, but you've not imported it into the code.

  5. #5
    slinkeey is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default

    This is code that you got from the following URL, right?

    Converting an IBM i Spool File to a PDF | IBM i | IBM Systems Magazine

    These are just code snippet examples. You can't just cut and paste the examples one after another into a text document with a java extension. For starters, you need to create the following methods.

    convertAFPDStoPDF
    convertSCStoPDF

    You also need to make sure that your as400 system object is referenced by the correct name.

    On one line you create an AS400 object called "iSeriesServer", but then you start referencing the AS400 object as "sys".

    After looking at what you pasted, I think that you need to start out a little smaller so that you can grasp the basics of java programming.

    Good luck on your adventure! We have all been there.

    Thanks,
    Jeff

Similar Threads

  1. HttpServlet Cannot be resolved to a type
    By chizbox in forum Eclipse
    Replies: 3
    Last Post: 07-01-2012, 05:09 PM
  2. Filter cannot be resolved to a type??
    By Harrie_KalaChakra in forum Eclipse
    Replies: 1
    Last Post: 01-15-2010, 09:19 AM
  3. Error - "The import org.junit cannot be resolved"
    By Jessaurum in forum New To Java
    Replies: 7
    Last Post: 11-03-2009, 03:20 AM
  4. [SOLVED] JavaMail on AS400 Authentication error
    By StormyWaters in forum Advanced Java
    Replies: 8
    Last Post: 06-02-2009, 03:00 PM
  5. Replies: 1
    Last Post: 12-18-2007, 10:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •