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 :
4) Restart coldfusion 9 Server
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.
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.
Related
I am new to Axis , I am trying to start Axis2 as a Standalone Server using the Standard Binary Distribution package in Linux. I went through this guide: https://axis.apache.org/axis2/java/core/docs/installationguide.html
I have downloaded and unpacked the distribution in it's own directory and i have also set environment variables AXIS2_HOME and JAVA_HOME as follows :
export AXIS2_HOME=/opt/axis2-1.8.2
echo $AXIS2_HOME returns
/opt/axis2-1.8.2
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
echo $JAVA_HOME returns
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
When trying to run axis2server.sh which is essentially the script to start the server I get the following prompts :
user#serverFoo/opt/axis2-1.8.2/bin$ ./axis2server.sh
Using AXIS2_HOME: /opt/axis2-1.8.2
Using JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
Error: Could not find or load main class org.apache.axis2.transport.SimpleAxis2Server
Coming from a JAVA background I understand that it can't find or load the server class, although I can't find any resources in the web pointing to the specific error .
EDIT : I have also added CLASSPATH variable pointing to the AXIS2_HOME/lib directory i.e
export CLASSPATH=/opt/axis2-1.8.2/lib/*.jar but still the same .
Any ideas would be welcome.
Thanks
I'm using Delphi 10.1 Berlin. I want to call Java codes from Delphi. So, I created JAR file in Android Studio (this link helped to me). Then I opened Java2OP.exe from C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op directory. I moved the jar file to this directory. Then I worked this commands in CMD:
SET PATH=%PATH%;"C:\Program Files\Java\jdk1.8.0_60\bin"
Java2OP.exe -jar ..\libmylib.jar -unit ..\Androidapi.JNI.MyLib
But I get this error:
Warning: error opening ReservedWordsOP.txt
Warning: error opening ReservedWordsC.txt
Parsing xml: C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op\bootclasses.xml
Parsing jar: ..\libmylib.jar
class or Interface expected
This my Java class for JAR:
public class Test
{
public String work()
{
return "Hello World!";
}
}
Also I tried different Java codes, but result is same. How can I solve this problem?
I have the same problem, and solved it removing spaces from path files.
Probably the Java2OP is calling the Java passing the path without quotes.
I am new to linux. I am trying to load a SO file in Ubuntu using Java. The file that I have specified in the java method "System.load(/home/ab/Downloads/libtesseract.so)" loads fine but its dependent so file placed in the same place as "libtesseract.so" is not found. Here is the error message I get. Error: UnSatisfiedLinkError and says "liblept.so.4" cound not be found. This so file is placed in the same location as libtesseract.so. When I place "liblept.so.4" in the "/lib". It is able to load this so file from. So what I understood is that for, its not for java to load the dependent so. It has to be loaded by ubuntu. So I tried a simple application to load this by setting the PATH variable with the location of the so file. And exported the java code into a jar and tried to run this jar file from terminal as the path variable is not persistent for entire system. It worked fine. So I tried to do the same thing programmatically by using the code below to its not working. Please advice. TIA
Code:
ProcessBuilder pb = new ProcessBuilder("/bin/sh");
Map<String, String> envMap = pb.environment();
envMap.put("LD_LIBRARY_PATH", "/home/ab/Downloads");
envMap.put("PATH", "/home/ab/Downloads");
Set<String> keys = envMap.keySet();
for(String key:keys)
{
System.out.println(key+" ==> "+envMap.get(key));
}
System.load("/home/ab/Downloads/libtesseract.so");
As far as I know you can't really modify the environment variables in Java "on-the-fly". That means you should set both LD_LIBRARY_PATH and PATH before running the java.
I am running maxent from R, in the package biomod2 and the following error appeared. I do not come from a technical background and wasn't sure why is this error happening. Is it a memory problem or someone said the java path is not set. But I followed the instructions to set maxent to run in R and also downloaded Java Platform, Standard Edition Development Kit and set a path for it as explained in this pdf: http://modata.ceoe.udel.edu/dev/dhaulsee/class_rcode/r_pkgmanuals/MAXENT4R_directions.pdf
I would be really grateful if you could help me understand this problem and any solution to it.
Thanks a lot
Error in file(file, "rt") : cannot open the connection
In addition: Warning messages:
1: running command 'java' had status 1
2: running command 'java -mx512m -jar E:\bioclim_2.5min\model/maxent.jar environmentallayers
="rainfed/models/1432733200/m_47203134/Back_swd.csv"
samplesfile="rainfed/models/1432733200/m_47203134/Sp_swd.csv"
projectionlayers="rainfed/models/1432733200/m_47203134/Predictions/Pred_swd.csv"
outputdirectory="rainfed/models/1432733200/rainfed_PA1_Full_MAXENT_outputs"
outputformat=logistic redoifexists visible=FALSE linear=TRUE quadratic=TRUE
product=TRUE threshold=TRUE hinge=TRUE lq2lqptthreshold=80 l2lqthreshold=10
hingethreshold=15 beta_threshold=-1 beta_categorical=-1 beta_lqp=-1
beta_hinge=-1 defaultprevalence=0.5 autorun nowarnings notooltips
noaddsamplestobackground' had status 1
3: In file(file, "rt") :
cannot open file 'rainfed/models/1432733200/rainfed_PA1_Full_MAXENT_outputs/rainfed_PA1_
Full_Pred_swd.csv': No such file or directory
I've just manage to solve this problem - it is a problem with the file path specified. For me, I had a space in one of the folder names which was not accepted in the path to the maxent.jar file. From looking at your error, it looks like it might be the two backslashes.
E:\bioclim_2.5min\model/maxent.jar
should probably read
E:/bioclim_2.5min/model/maxent.jar
While trying to run the following code from django application's views
Code: views.py
def tika(fileName):
os.popen('java -jar tika-app.jar -t %s > textOutput.txt' % fileName)
return 0
....
# filepath == path to a file
# call java applications
tika(filepath)
....
I get the following error messages:
Error: Unable to access jarfile tika-app.jar
I feel that it has something to do with file permissions for django application, but this is just my guess.
If it might help to know - the java application is in the same directory as the django app.
Found the part that was causing the problem:
The java application should be in the Django's project directory level and not at the Django's application directory level.
Lesson from this: Even though the running code (views.py) is in the Django's application level, it is run from one level up - the project level.