0

I have a java program (1 .java file and 2 .class files) that I am trying to run. I was told to use the command "java Downloader [-file filename] [-log log-file] [-host hostname] username password GMAT-program-code" to run it. This works fine in the command prompt. But when I try to run it in the command prompt through coldfusion, it does nothing. I don't get an error, but it also doesn't create any files/logs as it should. I tried many variations, including:

<cfexecute name="#datadrop#\Downloader\jre1.5\bin\java.exe" arguments="java Downloader *username* *password* *test*" outputFile="#logs#\thisone.txt"></cfexecute>
<cfexecute name="C:\Windows\System32\cmd.exe" arguments="c/ downloadscript.bat" outputFile = "filename.txt"></cfexecute>
<cfexecute name="C:\Windows\System32\cmd.exe" arguments="c/ cd Downloader/src & Downloader *username* *password* *test*" outputFile = "#logs#/filename.txt"></cfexecute>

I did some googling, and most documentation shows to do this is by using cfobject. I placed the 2 classes in the classpath folder and tried to implement this by doing:

<cfobject action="create" type="java" class="Downloader" name="pvdl"> 
<cfset pvdl.username="*username*"> 
<cfset pvdl.pword="*password*"> 
<cfset pvdl.test='*test*'> 

This errors out and says: The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request USERNAME

Can anyone help me in getting this program running? The preferred method is to use the command line.

Thanks.

Lauren Robinson
  • 443
  • 2
  • 9
  • 26
  • If this is a basic download, any reason you cannot use cfhttp instead? That said, a couple suggestions a) What does downloadscript.bat do? b) The directly context of cfexecute may be different than you are expecting. Best to use absolute paths for *all* file references c) Did you use the error variables to check for problems AND check all CF log files cf_root\logs and runtime\logs – Leigh Apr 01 '15 at 14:03
  • *Error Occurred While Processing Request USERNAME* Hard to say without the complete message, but it looks like an undefined variable error. Also, it does not look like you are passing the variables to the object correctly. Typically you pass arguments into a specific method of the object ie `pvdl.someMethod( arg1, arg2, ....)`. We would have to see the method signature to be more specific. Does it have a public API? – Leigh Apr 01 '15 at 15:19

1 Answers1

0

Sorry to hear this is a problem. I have a question. When you say java downloader are you refering to this: Javaloader Have you tried following this set of instructions on github?

I have worked with it in the past and what I can remember is that you take your jar file and drop it in the javaloader path where it pick it up when you create your object.

Here is a very robust conversation about javaloader (right here on SO): How to setup java libraries with javaloader in Coldfusion8?

And this one here: ColdFusion using Javaloader error

Here is a good structure I found to follow:

<cfscript>
variables.jarsPaths = ArrayNew(1);
variables.jarPaths[1] = ExpandPath("poi/poi-3.9-20121203.jar");
variables.jl = CreateObject("component", "javaloader.JavaLoader").init(variables.jarPaths);
</cfscript>

Here is a nice page that has some javaloader tips: http://www.mindfiresolutions.com/JavaLoader-in-Coldfusion-1328.php

Basically I think the worst of your troubles will be getting your pathing in your object right.

Hope some of these things help.

Community
  • 1
  • 1
Frank Tudor
  • 4,226
  • 2
  • 23
  • 43