• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Java object failed to create

Explorer ,
Feb 16, 2012 Feb 16, 2012

Copy link to clipboard

Copied

Hi everyone,

  I have a Java class and want to deploy it in ColdFusion. I put the class file at C:\ColdFusion9\wwwroot\web-inf\classes. However, on my Vista machine everything works fine. But it fails on my windows7 machine. On windows7, It seems that the page that uses this Java object simply stop working. The page displays the navigation menu at the very top first, then it supposes to display some messages output by this object but it does not. And on that page any code after the Java object creation does not get executed. The only thing this page displays is the navigation bar and the background color. I suspect this may have something to do with Vista being 32 bit and windows 7 being a 64-bit machine? Is this correct? Anyone encountered the same problem before and knows the answer?

Thanks in advance for helping!!

Views

5.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

After reading the first few sentences of your description I, too, thought of bitness. However, you should in general be able to carry 32-bit applications over to 64-bit environments. But there could be exceptions.

I would expect such exceptions only when you, for example, change the bitness of the JVM. Which makes me to ask, is the version of ColdFusion on Windows 7 64-bit?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

In Windows 7 there are two program files folder, one called 'Program FIles' for 64-bit software and the other called 'Program Files(x86)' for 32-bit software. Both Program FIles have Java folder there. We don't know, it all depends on how ColdFusion interact with JVM. Only ColdFusion team knows why...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

I was talking about ColdFusion, which ships with its own JVM by default. Is the version of ColdFusion 9 you installed on Windows 7 32-bit or 64-bit?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

Thank you. My problem solved. I believe I installed 64-bit version. I know my Windows 7 machine is 64 bit machine. so I always consider 64-bit version first when I install a software. But to be honest, I don't know how to confirm this. Where can I look for to find out whether I installed 32-bit or 64-bit ColdFusion?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

ffcai wrote:

Where can I look for to find out whether I installed 32-bit or 64-bit ColdFusion?

Open the ColdFusion Administrator. Click on the i (for System Information) in the top right-hand corner.

Scroll down the table to the value of Java VM Name. If it is 'Java HotSpot(TM) Server VM' then your ColdFusion is 32-bit. If it is 'Java HotSpot(TM) 64-Bit Server VM' then your ColdFusion is 64-bit.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Java VM NameJava HotSpot(TM) 64-Bit Server VM 

So I remember it right. It is 64 bit. The only explanation is Java 7 is too new for ColdFusion 9 to use.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

I suspect this may have something to do with Vista being 32 bit and windows 7 being a 64-bit machine? Is this correct?

Java is mostly platform neutral. So it is possible, but less likely to be the cause.

What does this class do in general terms? Also, what is the error message thrown? Check the error logs too.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

Thanks for reminding me. I did not look at the log before. Here is the message:

"Error","web-5","02/16/12","18:25:13","xqc","HelloWorld : Unsupported major.minor version 51.0 The specific sequence of files included or processed is: C:\ColdFusion9\wwwroot\xqc\index.cfm, line: 18 "

Based on the message, I strongly felt the Java version installed was the problem. I went ahead to prove it. I copied the Java class from my Vista machine to my Windows 7 machine. It worked! If I remember it right, my Vista machine produce something with version 50. My Vista has Java 6 installed. My Windows 7 has Java 7 installed. It seems the JVM comes with ColdFusion does not recognize class files produced by Java 7 yet. Problem solved. Thank you BKBK and cfSearching. I will need to develop and compile the Java classes on my Vista machine, then copy them over to Windows 7...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

It seems the JVM comes with ColdFusion does not recognize class files produced by Java 7 yet.

Maybe I need more coffee, but you lost me 😉 ... What you are describing does quite match up with the original description:

      "I put the class file at C:\ColdFusion9\wwwroot\web-inf\classes. However, on my Vista machine everything works fine. But it fails on my windows7 machine." 

... that suggests the original class was compiled on Vista 32 bit using the jvm that ships with CF9 (1.6). I am not sure where java 7 entered the picture.  What version of java did you use to compile the original class? Also, which verison of java is CF9 using on both machines?

Message was edited by: -==cfSearching==-

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

My Vista machine has ColdFusion9, Java6 installed. My Windows7 machine has ColdFusion9, Java7 installed. I used Java6 to compile the Java file on Vista, and used Java7 to compile the Java file on Windows7. CF9 comes with JVM, but not the JDK. CF9 can only run class file, but it can't produce class file. My original Java file was compiled both on Vista and WIndows7 respectively. Hope this clarify it.

Also, I found the following infor in 'i" page in CF Administrator.

Java Class Version50.0 

So obviously CF9 only recognize Java Class Version 50. The Java class file produced by Java7 is versioned 51. I believe this will get udpated in CF10.

Have a good weekend.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Also, I found the following infor in 'i" page in CF Administrator.

Java Class Version | 50.0

Oh ... that explains it.  Your ColdFusion instance is using java 1.6.

and used Java7 to compile the Java file

Now the original error makes sense.  When you compile with the default settings, the generated class files are not backward compatible. They are marked to require whatever java version you used to compile them. Since you compiled with java 7, the classes can only be used with java 7 (or higher). Since your ColdFusion instance is running an earlier version (ie 1.6) it obviously cannot load those classes.

If you want the classes to be backward compatible, you need to use the "-target" flag when compiling. Or better yet, just download the compatible jdk (1.6), since CF9 does not officially support java 7 anyway.

So obviously CF9 only recognize Java Class Version 50. The Java class file produced by Java7 is versioned 51. I believe this will get udpated in CF10.

It is not really about the ColdFusion version, so much as the jvm version used by ColdFusion.  "Class version" is used to determine compatibility of java code. However, it comes from the java system properties, not ColdFusion. So it changes depending on which jvm is listed in the ColdFusion Administrator.  Unless CF10 ships with java 7 (which I do not think it does) the class version will remain 50.0.

         java 1.4.2 => class version is 48.0

         java 1.5.x => class version is 49.0

         java 1.6.x => class version is 50.0

         java 7.x.x  => class version is 51.0

CF9 comes with JVM, but not the JDK. CF9 can only run class file, but it can't produce class file.

Well .. ColdFusion can produce class files. Otherwise none of your CF applications would work ;-). But yeah, you are right that the standard jre does not include the command line compiler: javac.exe. That is only included in the jdk.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

Thanks for so much information. I have used Java for many years but never have a chance to meet '-target' option. I try to use it this time with this command "javac -target 1.6 HelloWorld.java", of course without quotation.  I received this message "javac: target release 1.6 conflicts with default source release 1.7". I went on to try it using version number 1.1 through 1.5, none of them work. Lastly I tried 1.7 and it did compile. So somehow jkd1.7 is in conflict with all the previous version?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

ffcai wrote:

Thanks for so much information. I have used Java for many years but never have a chance to meet '-target' option. I try to use it this time with this command "javac -target 1.6 HelloWorld.java", of course without quotation.  I received this message "javac: target release 1.6 conflicts with default source release 1.7". I went on to try it using version number 1.1 through 1.5, none of them work. Lastly I tried 1.7 and it did compile. So somehow jkd1.7 is in conflict with all the previous version?

You are almost there. You had to specify the source, of course. Do this

javac -source 1.7 -target 1.6 HelloWorld.java

and you will be on your way.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

Thank you BK. But 1.7 is already the default source, isn't it? I don't think we need to specify it again on the command line directly. But I do give it a shot with your suggestion. This is what I received after I run the command you provided "javac: source release 1.7 requires target release 1.7".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

Wow, just tried to do it myself with the proverbial HelloWorld.java. Compilation failed indeed. A quick look on the web shows that that is a well known problem in Java 7. I'm looking for an alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

I could do it using Mark Mandel's Javaloader . Here are the steps I followed.

1) I downloaded javaloader_v1.1.zip, unzipped it, and copied the essential directory javaloader to c:\ColdFusion9\wwwroot\.

2) I created a directory called myClasses within c:\ColdFusion9\wwwroot\WEB-INF\classes\, and copied my file, HelloWorld.java, into it.

3) I created a directory called myJARs within c:\ColdFusion9\lib\. The Javaloader application will need it to store the JAR files I compile.

4) I then stored the following code as compilationTest.cfm:

<cfset javaloader = createobject("component","javaloader.javacompiler").init("C:\ColdFusion9\lib\myJARs")>

<!--- array of directories holding Java source files --->

<cfset mySourceDirs = arrayNew(1)>

<cfset mySourceDirs[1] = "C:\ColdFusion9\wwwroot\WEB-INF\classes\myClasses">

<cfset myJAR = javaloader.compile(directoryArray=mySourceDirs, jarName="myCompiledFiles.jar")>

Done compiling

5) When I ran compilationTest.cfm, ColdFusion duly compiled the Java file. It created the following 2 files:

C:\ColdFusion9\wwwroot\WEB-INF\classes\myClasses\HelloWorld.class

C:\ColdFusion9\lib\myJARs\myCompiledFiles.jar

6) I then copied the class file one directory higher, to C:\ColdFusion9\wwwroot\WEB-INF\classes\, and I was ready to go. If I was dealing with a large number of Java source files, grouped, say, in an application, then I would have instead chosen to use the JAR. I would then simply have copied the file myCompiledFiles.jar into C:\ColdFusion9\lib\.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

Thanks for teaching me one more thing. I know Gurus alway can find a work around.

But I personally don't like to install many redundant software in my pc. If I have JDK, JRE installed, I am quite relunctant to install something like Mark Mandel's Javaloader. Besides, do I need to install Mark Mandel's Javaloader on a production server? I think to keep it simple, I would prefer to develop the Java utility files in Vista, fully test it. Then copy it over to Windows7 to test with ColdFusion.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

I agree with you. If your intention is just to compile a few Java files, then installing the Javaloader will be too much of a good thing. Compiling on the Vista machine and then copying to ColdFusion on Windows 7 is preferable at the moment.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

Try this (yes, on Java 7 on Windows 7!):

javac -source 1.6 -target 1.6 HelloWorld.java

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

WOW, I was shocked. it works! I finally can do everything in one machine. Thanks a lot!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 18, 2012 Feb 18, 2012

Copy link to clipboard

Copied

I also recommend CF team come up with some sort of patch for updating its internal JVM everytime a new Java version is released. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

I have used Java for many years but never have a chance to meet '-target' option.

My bad. It has been a while since I have used the command line compiler. (I usually go through Eclipse, for compiling jars). So I had to look it up myself 😉  Both of these worked with 1.7.0_03 with a simple test class. Though it generated a warning.  (See: Source and target file decoder)

      c:\path\to\java7\bin\>   javac -source 1.6 c:\dev\MyTestClass.java

      c:\path\to\java7\bin\>   javac -source 1.6 -target 1.6 c:\dev\MyTestClass.java

But according to this article you may also want to supply the bootstrapclasspath of the older jvm in some cases.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

(Ugh... formatting with this forum software is such fun...)

I also recommend CF team come up with some sort of patch for updating its internal JVM everytime a new Java version is released.

Edit:  Since the jvm is so critical, I do not think the jvm of an existing instance should be changed automatically.

I seem to recall reading about some issues with java 7. So the decision to stick with 1.6 was probably deliberate. However, you can easily update the jvm path yourself, assuming the version is compatible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2012 Feb 19, 2012

Copy link to clipboard

Copied

You are right. Thanks a lot!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation