I've just tried to compile the same file with a JavaCompiler.cfc bundled in the latest version of Mark's JavaLoader.
And, guess what, the compiled classes do get loaded properly.
So is there a problem with javac that I use? Is it too new for ColdFusion 10? Or are there any special setting I have to consider when compile java files?
Actually there is a reason, why using the JavaCompiler.cfc will not work for me. I actually want to try to use Scala, and that's why I need to be able to use external compiler. By the way, if anybody here managed to load Scala classes into ColdFusion, please please please do share you experience.
1 person found this helpful
I create an Employee.java file and compile it with javac (I think mine one is from jdk1.7.0_02).
That probably caused the problem. ColdFusion 10 is based on Java 1.6.x. So compile the file with JDK1.6.x and restart the entire process.
Thanks for the response! Indeed, classes compiled with the following flags are loaded into ColdFusion and work properly:
>javac -source 1.6 -target 1.6 Employee.java
I know some people have mentioned on the internet that they have working Scala code in ColdFusion but unfortunately they reveal no details.
What if I choose an option not to compile java file for jdk1.6, but to change ColdFusion's java.home to work with jdk1.7. Should this solve the problem?
The reason I am asking is that I've created a module (a jar file with lots Java/Scala libraries packed into it), which uses a lot of external java libraries, and when I am trying to run a certain function from this module, I again encounter the same problem – the output of the page cuts off after the call to that function. I do manage to load the class from this .jar file and everything works fine until I call a certain method of this class (this method uses a lot of libraries internally). After a call to this method, the output of the page is cut off.
At first I thought that probably one of the libraries is built for jdk1.7, and when this library is used in my module, then the problem occurs. Indeed I found among the libraries that there is a Netty-3.4.4.Final library for which it is said in the manifest file that the jdk is 1.7 (though on the projects GutHub page it is said that Netty needs jdk 1.7 to compile but will run on jdk from 1.5).
Then, remembering your words about CF10 update to Java 7, I started to look for possibilities to run CF10 on jdk1.7, and I actually managed to do it (by changing java.home). I hoped this would solve the problem with jdk1.7 java libraries, but unfortunately it did not.
As you yourself have discovered, if you configure Coldfusion 10 to work with Java 1.7, it may run the files you compiled with JDK1.7, however it wont run a lot of ColdFusion's own system files! That is because ColdFusion 10's Java libraries are compatible with Java 1.6.
Those are the current Java upgrade rules for ColdFusion. However, be patient. The ColdFusion Team's Hemant Khandelwal says ColdFusion 10 will soon support Java 1.7.