3

Im using Coldfusion 9 with Multiserver/J2EE on JRun 4 Configuration in a development engine.

I try to apply sample below into my coldfusion engine however it not work.

Sample : How do you use java files in Coldfusion

Perhaps anyone here can help me to resolve this issue?

Here is what i did :

1) Write a simple Hello.java file, compile into Hello.class file.

public class Hello 
{ 
    public String testJava() 
    { 
    return "Hello Java!!"; 
    } 
}

2) Write a cfm file : jHello.cfm to call the java object.

    <cfscript>
       helloWorld = CreateObject("java","Hello");
       helloTest = helloWorld.testJava();
    </cfscript>

3) Save the .class file into class path : enter image description here

4) Restart coldfusion 9 Server enter image description here

5) However, it return Error below when run JHello.cfm file :

Object Instantiation Exception.

    Class not found: Hello
     
    The error occurred in C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/accuity_dev/JHello.cfm: line 2
    1 : <cfscript>
    2 :    helloWorld = CreateObject("java","Hello");
    3 :    helloTest = helloWorld.testJava();
    4 : </cfscript>

Appreciate your time, hope can get back from any expert here.

Community
  • 1
  • 1
keonglah
  • 113
  • 1
  • 6
  • Nothing jumps out as obviously wrong, except maybe the location of the compiled .class file. It if it is placed in the wrong directory, obviously CF won't pick it up. See [Adding to ColdFusion Classpath for Particular Instance in Multi-Server Adobe Coldfusion 9](http://stackoverflow.com/questions/15505738/adding-to-coldfusion-classpath-for-particular-instance-in-multi-server-adobe-col) – Leigh Feb 21 '17 at 13:55

1 Answers1

0

Do you have access to CF administrator page? I see a ear/war in path indicating a different configuration than what I have tried or used before. I have done multiple instances but not with J2EE ear/war.

If you can access administrator page, then go to java/jvm settings page. In that, put the full absolute path of the .class file and hit submit. You will have to restart CF.

Note : this is no different than editing the jvm.config file but you dont have to worry about syntax especially windows vs linux, forward slash or back slash. Finally, please make a backup of jvm.config before making any changes via CF administrator.

ah7866
  • 136
  • 3