Java

Hi. How can I call a Java class from builder?I've tried builder's class JavaObject, but when I've called JavaObject dateFormat = JavaObject.New( "com.opentext.util.DateFormat", {} )I've got E1114112008. I have the latest jre installed. What's wrong? Thanks for advices, Tomas Kutlak

Comments

  • Hi Tomas, The problem you run into is that by default the JavaVM is not loaded when you start the builder. Search the KC for loadjavaVM to find how the javaVM can be loaded with the builder. Hans
  • It's going well now. Thank you. Tomas
  • Hi Hans,

    JavaObject fileObj = JavaObject.New( "java.io.File", { "c:" } )
    JavaObject dateFormat = JavaObject.New( "com.opentext.util.DateFormat", {} )

    The first one worked (JVM started with builder)

    and second one gave me "E1114112001", could not find the class. Any idea?


     

  • Hi,

     

    I expect that the proper classes are not loaded.

     

    Hans

     

     

     

    From: eLink Entry: Content Server Builder Forum [mailto:componentbuilder@elinkkc.opentext.com]
    Sent: Mittwoch, 4. Mai 2011 13:56
    To: eLink Recipient
    Subject: Java in the Builder

     

    Java in the Builder

     

    Posted by kevin@linkecm.com (Lin, Kevin) On 2011/05/04 07:55

     

     

    Hi Hans,

    JavaObject fileObj = JavaObject.New( "java.io.File", { "c:" } )
    JavaObject dateFormat = JavaObject.New( "com.opentext.util.DateFormat", {} )

    The first one worked (JVM started with builder)

    and second one gave me "E1114112001", could not find the class. Any idea?


     


    [To post a comment, use the normal reply function]

    Topic:

    Java

    Forum:

    Content Server Builder Forum

    Livelink Server:

    knowledge-wlweb01

     

  • Afaik a class com.opentext.util.DateFormat does not exist.Did you mean java.text.SimpleDateFormat ?
  • I am also having trouble. 

    The docs say to do the following:

    1) In order to use JavaObject, Livelink JVM has to be started. However, unlike Livelink service, Livelink Builder does not start the JVM by default. To start the JVM in Livelink Builder, add "-loadjavavm" in the Target field of the Livelink Builder's program shortcut.
    2) To deploy your jar files in Livelink JVM, added the jar files in OTHOME/ojlib/ or OTHOME/module/somemodule_1_0_0/ojlib/ directory (and their subdirectories) to be recognized by the JVM's application classloader.
     

    C:\OPENTEXT\bin\llbuilder.exe webbuilder.lxe C:\OPENTEXT\config\opentext.ini -loadjavavm

    I have the jar files in both the <ModuleName>\ojlib as well as the OpenText\ojlib directories. 

    I can load instantiate a standard java object like so:

    JavaObject lc1 = JavaObject.New( "java.io.File", {fileName} )

    However, attempting to instantiate something from my own jar file doesnt work:

    String pkgClass = "com.vdr.PropWriterTest1.Test1"
    JavaObject     testObj = JavaObject.New( pkgClass, {} )
     

    The error is:

    E1114112001 ("Could not find the class definition.")

    It seems to be a class path issue or something similar as I can load up the java.io.File class, but I'm at a loss as to what I'm doing wrong.  I double checked the package segments, even copied them out of the source in NetBeans.

    The relevant code from the java class is:

    package com.vdr.PropWriterTest1;
    public class Test1 {
    ...

    }

    I have also successfully tested this class from within NetBeans.

     

  • The problem was that I had compiled the jar file under Java 7 and CS uses Java 6.  Once I retargeted the package and rebuilt it I was able to load it.