Problem calling oracle SP from Java
Hi I am trying to call an oracle SP from Java program and getting the error code 17060. Below is my code:
Oracle SP:
create or replace type item as object (itemnumber varchar2(9),itemdesc varchar2(35));
create or replace type uom as object (prodUOM varchar2(18), ratioDen NUMBER(1));
CREATE OR REPLACE TYPE uom_Arr aS VARRAY(100) OF uom;
create or replace package test_pkg_xml is
procedure test_sp_xml (item_rec item,
uom_tbl uom_arr);
end test_pkg_xml;
create or replace package body test_pkg_xml is
procedure test_sp_xml (item_rec item,
uom_tbl uom_arr)
is
begin
null;
end;
end test_pkg_xml;
Java Code
public class item implements SQLData {
private String sql_type;
public String itemnumber ;
public String itemdesc ;
public String getSQLTypeName() throws SQLException { return sql_type; }
public void readSQL(SQLInput stream, String typeName)throws SQLException
sql_type = typeName;
itemnumber = stream.readString();
itemdesc = stream.readString();
public void writeSQL(SQLOutput stream) throws SQLException
System.out.println("in write sql");
stream.writeString (itemnumber);
stream.writeString (itemdesc);
package com.tgt.dstb.dwm.dstbtowm.dao;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.sql.Connection;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Types;
import java.sql.SQLException;
import java.util.Map;
import java.util.Hashtable;
public class TestDOM
public static void test(Connection conn) throws Exception
item obj1 = new item();
Obj2 obj2 = new Obj2();
Obj2[] obj3 = {new Obj2(), new Obj2()};
String sql = "call " + "test_pkg_xml.test_sp_xml(?,?)";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse( "item.xml" );
Element itemMaster = document.getDocumentElement();
NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
System.out.println("Item = ");
String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
obj1.itemnumber = itmname;
obj1.itemdesc = itmdesc;
System.out.println("itmname = " + obj1.itemnumber );
System.out.println("itmdesc = " + obj1.itemdesc );
NodeList uoms = itemMaster.getElementsByTagName("uoms");
NodeList uom = itemMaster.getElementsByTagName("uom");
System.out.println("uom = ");
for( int i=0; i<uom.getLength(); i++ ) {
String itmprodUOM = DOMUtil.getSimpleElementText(
(Element)uom.item(i),"prodUOM" );
obj3.prodUOM = itmprodUOM;
String itmratioDen = DOMUtil.getSimpleElementText(
(Element)uom.item(i), "ratioDen" );
obj3[i].ratioDen = itmratioDen;
System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
try
Hashtable map = new Hashtable();
map.put ("item", Class.forName ("com.tgt.dstb.dwm.dstbtowm.dao.item"));
conn.setTypeMap(map);
System.out.println("here 11111 ");
CallableStatement stmt = conn.prepareCall("call test_pkg_xml.test_sp_xml(?,?)");
System.out.println("here 2 ");
stmt.setObject(1,obj1);
System.out.println("here 3 ");
stmt.setObject(2,obj3);
System.out.println("here 4 ");
stmt.execute();
System.out.println("here 5 ");
}catch (SQLException e)
System.out.println("exception :"+e.getErrorCode());
Can you please point out where I might be going wrong with the code? Any help would be greatly appreciated.
PS : I am getting the error 17060 after the stmt : System.out.println("here 2 ");
Thanks,
Nitin
Avi, I changed my code to:
package com.tgt.dstb.dwm.dstbtowm.dao;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.sql.Connection;
//import java.sql.CallableStatement;
import java.sql.*;
//import java.util.Map;
//import java.util.Hashtable;
import oracle.sql.ArrayDescriptor;
import oracle.sql.*;
import oracle.jdbc.*;
public class TestDOM
public static void test(Connection conn) throws Exception
item obj1 = new item();
Obj2 obj2 = new Obj2();
Obj2[] obj3 = {new Obj2(), new Obj2()};
String sql = " call test_pkg_xml.test_sp_xml(?,?)";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse( "item.xml" );
Element itemMaster = document.getDocumentElement();
NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
System.out.println("Item = ");
String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
obj1.itemnumber = itmname;
obj1.itemdesc = itmdesc;
System.out.println("itmname = " + obj1.itemnumber );
System.out.println("itmdesc = " + obj1.itemdesc );
NodeList uoms = itemMaster.getElementsByTagName("uoms");
NodeList uom = itemMaster.getElementsByTagName("uom");
System.out.println("uom = ");
for( int i=0; i<uom.getLength(); i++ ) {
String itmprodUOM = DOMUtil.getSimpleElementText(
(Element)uom.item(i),"prodUOM" );
obj3.prodUOM = itmprodUOM;
String itmratioDen = DOMUtil.getSimpleElementText(
(Element)uom.item(i), "ratioDen" );
obj3[i].ratioDen = Integer.parseInt(itmratioDen);
System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
try
System.out.println("here 1 ");
OracleCallableStatement stmt = (OracleCallableStatement)
conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");
System.out.println("here 1.1 ");
System.out.println("here 1.2 ");
ArrayDescriptor desc1 = ArrayDescriptor.createDescriptor("UOM_ARR", conn);
ARRAY array_to_pass1 = new ARRAY(desc1, conn, obj3);
System.out.println("here 2 ");
stmt.setObject(1,obj1,OracleTypes.STRUCT);
System.out.println("here 3 ");
stmt.setArray(2,array_to_pass1);
System.out.println("here 4 ");
stmt.execute();
System.out.println("here 5 ");
}catch (Exception e)
e.printStackTrace();
However, now I the code is printing
"here 1 "
and then giving
"[1/4/07 11:37:28:133 CST] 00000036 SystemErr R java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement"
at "OracleCallableStatement stmt = (OracleCallableStatement)
conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");"
statement.
I am using Rational App Developer Version 6.0.1 and getting a connection using
the below code:
DataSource dataSource=null ;
Context jndiContext = new InitialContext();
dataSource =
(DataSource)jndiContext.lookup("java:comp/env/jdbc/DWM3DDS");
Connection wsConn = dataSource.getConnection();
Looks like this exception occurs when I am casting java.sql.Connection object to OracleCallableStatement. Do you have any idea why this might be occuring? Have you encountered this kind of a problem?
Thanks,
Nitin
Similar Messages
-
Calling oracle reports from java applications
Hi:
I was wondering if anyone can tell me how to invoke an oracle report from a java application.yes it is possible. There is a cgi script called viewreport.cgi. Have the jsp page call it (GET or POST method) and place the user parameters inside the form.
-
Problem calling Oracle function from Access 2007 / ADO
Hopefully, I'm posting this in the correct forum. I'm also posting on an Access forum as I'm not entirely sure where the issue lies.
I'm calling an Oracle function from Access 2007 using an ADO Command object.
The function takes three input parameters and has a return value and an output parameter. The output parameter is a BLOB, and the return value is varchar2 (either "T" or "N") based on the outcome of the function.
If I pass correct values to the function, I get the following error message (errs out on the command.execute line):
Run-time error '-2147467259 (80004005)':
[Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 1
Here's the function:
FUNCTION GET_ITEMREV_ATTACH(P_ORGANIZATION_ID IN NUMBER,
P_INVENTORY_ITEM_ID IN NUMBER,
P_REVISION IN VARCHAR2,
X_DRAWING OUT BLOB) RETURN VARCHAR2 IS
RESULT VARCHAR2(1);
BEGIN
RESULT := 'T';
BEGIN
SELECT L.FILE_DATA
INTO X_DRAWING
FROM FND_ATTACHED_DOCUMENTS AD,
MTL_ITEM_REVISIONS_B IR,
FND_DOCUMENTS_TL D,
FND_LOBS L
WHERE AD.ENTITY_NAME = 'MTL_ITEM_REVISIONS' AND
AD.PK1_VALUE = IR.ORGANIZATION_ID AND
AD.PK2_VALUE = IR.INVENTORY_ITEM_ID AND
AD.PK3_VALUE = IR.REVISION_ID AND
AD.CATEGORY_ID = 1001216 AND
D.DOCUMENT_ID = AD.DOCUMENT_ID AND
D.LANGUAGE = 'US' AND
L.FILE_ID = D.MEDIA_ID AND
IR.ORGANIZATION_ID = P_ORGANIZATION_ID AND
IR.INVENTORY_ITEM_ID = P_INVENTORY_ITEM_ID AND
IR.REVISION = P_REVISION;
EXCEPTION
WHEN OTHERS THEN
RESULT := 'N';
END;
RETURN(RESULT);
END GET_ITEMREV_ATTACH;
Here's the VB code I'm using to call the function:
Private Sub Command8_Click()
Dim CMD As New ADODB.Command
Dim conn As ADODB.Connection
Dim Param1 As ADODB.Parameter
Dim Param2 As ADODB.Parameter
Dim Param3 As ADODB.Parameter
Dim ParamBlob As ADODB.Parameter
Dim ParamReturn As ADODB.Parameter
Set conn = New ADODB.Connection
With conn
.ConnectionString = "Driver={Oracle in OraHome92};Dbq=OAPLY;UID=***;PWD=*******"
.CursorLocation = adUseClient
.Open
End With
Set CMD = New ADODB.Command
Set CMD.ActiveConnection = conn
CMD.CommandText = "immi_attach_pub.get_itemrev_attach"
CMD.CommandType = adCmdStoredProc
Set ParamReturn = CMD.CreateParameter("RESULT", adVarChar, adParamReturnValue, 1)
CMD.Parameters.Append ParamReturn
Set Param1 = CMD.CreateParameter("P_ORGANIZATION_ID", adInteger, adParamInput, 1, 6)
CMD.Parameters.Append Param1
Set Param2 = CMD.CreateParameter("P_INVENTORY_ITEM_ID", adInteger, adParamInput, 4, 5207)
CMD.Parameters.Append Param2
Set Param3 = CMD.CreateParameter("P_REVISION", adVarChar, adParamInput, 2, "04")
CMD.Parameters.Append Param3
Set ParamBlob = CMD.CreateParameter("X_DRAWING", adLongVarBinary, adParamOutput, 200000)
CMD.Parameters.Append ParamBlob
CMD.Execute , , adExecuteNoRecords *** this is where the error occurs
conn.Close
MsgBox CMD.Parameters("RESULT")
End Sub
I've tried using different data types for the varchar2 parameters (adVarChar, adBSTR, adChar) with no difference.
If I pass a bogus value for Param3...."'04'"...the function returns "N" indicating that it actually executed something. But, when I pass the correct value "04", it returns the above mentioned error.
I can execute the function in PL/SQL just fine, so I'm thinking there's something wrong with the parameters, datatype, or other definitions on the Access side.
Does anyone have any thoughts? I'm at a dead end with this. Sorry for the long post. Thank you.I tried your code with 11107 ODBC/client/database (but with a NULL output blob for convenience sake) and got no errors.
If you're using 92 ODBC/client, you may want to try upgrading to something more current, or at least getting the latest patch(9208) to see if that helps. Since it works for me I'm guessing it may be a resolved bug in that version.
Hope it helps,
Greg -
Problem in calling oracle procedure from java
Oracle procedure with the following parameters.
CREATE OR REPLACE PROCEDURE CREDITED_TO_STORE_INSERT (P_CUST# IN NUMBER,
P_INV_DATE IN DATE,
P_MEMO# IN NUMBER,
P_SESS_ID IN VARCHAR2 ) IS
BEGIN
/*.........Procedure Body with select and insert statements there no OUT or return variable/value......*/
END;
Now i am calling this procedure with the java code in java.
public boolean execProcedure(String storeNo, String invoiceDate, String claimNo, String sessionID) throws SQLException {
CallableStatement cstmt = null;
java.sql.Date invicDate = this.StringToDate(invoiceDate);
try
cstmt = conn.prepareCall("{call WEBUSER.CREDITED_TO_STORE_INSERT(?,?,?,?,?,?)}");
cstmt.setInt(1, Integer.parseInt(storeNo));
cstmt.setDate(2, invicDate);
cstmt.setInt(3, Integer.parseInt(claimNo));
cstmt.setString(4, sessionID);
cstmt.execute();
catch (Exception e)
System.out.println (e);
} // catch (Exception e)
finally
try
cstmt.close();
catch (Exception ex)
} // catch (Exception ex)
} // finally
return true;
But it will return the following exception.
[STDOUT] java.sql.SQLException: Missing IN or OUT parameter at index:: 5
i don't know why :( please help me ...your procedure has 4 parameters but in the prepared statement you define 6 placeholders
-
Calling oracle Function from java
first of all ... i don't know english very vell and sorry about it ..... then ...
i've created table in oracle :
create table STUDENT
ID NUMBER,
NAME VARCHAR2(50),
SURNAME VARCHAR2(50),
AGE NUMBER
and than i've wrote function like that :
create or replace function sf_SearchStudent
nID in number
return MyPackage.CursorType is
Result MyPackage.CursorType;
begin
open Result for select * from STUDENT where ID=nID;
return Result;
end sf_SearchStudent;
and it's working fine but in java i wrote code like that :
CallableStatement callst = conn.prepareCall("{?=call sf_SearchStudent(?,?,?,?)}");
callst.registerOutParameter(1, OracleTypes.CURSOR);
callst.setInt(1,id);
callst.setString(2,name);
callst.setString(3,surname);
callst.setInt(4,age);
callst.executeUpdate(); ------->>>>> ERROR Occur
ResultSet res = ((OracleCallableStatement)callst).getCursor(1);
while (res.next())
System.out.println(res.getInt("ID"));
System.out.println(res.getString("NAME"));
System.out.println(res.getString("SURNAME"));
System.out.println(res.getInt("AGE"));
but here is an error and i don't know why :( ....... please help me ..... F!
error type :
java.sql.SQLException: Missing IN or OUT parameter at index:: 5no it's not a problem ........ I so already tried, but a mistake all the same was. After that I a little bit simplified.
ok consequently i did oracle procedure like that :
create or replace function sf_SearchStudent
nID in number
return MyPackage.CursorType is
wCursor MyPackage.CursorType;
begin
open wCursor for Wselect;
return wCursor;
end sf_SearchStudent;
and the java source code looks like that :
CallableStatement callst = conn.prepareCall("{?=call sf_SearchStudent(?,?,?,?)}");
callst.registerOutParameter(1, OracleTypes.CURSOR);
callst.setString(1, name);
callst.executeUpdate(); ------------------>>>>>>>>>> HERE IS AN ERROR ------------<<<<<<<<<<<<
ResultSet res = ( (OracleCallableStatement) callst).getCursor(4);
while (res.next())
System.out.println(res.getInt("ID"));
System.out.println(res.getString("NAME"));
System.out.println(res.getString("SURNAME"));
System.out.println(res.getInt("AGE"));
error type :
java.sql.SQLException: Missing IN or OUT parameter at index:: 3 -
CALLING ORACLE STOREDPROCEDURES FROM JAVA
Hi friends
can anyone tell me how to use storedprocedures of Oracle with swings...
THANX IN ANTICIPATION
aLEXPlease check the following code:
CallableStatement cstmt = conn.prepareCall("{ ? = call inc_trace()}");
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.executeUpdate();
trace = cstmt.getInt(1);
Attention:
(1) you must use registerOutParameter() to set the return message;
(2) and, your must use setXXX methods to set parameters.
Hope this help!
Jack -
Problem when calling a report from java
Hi all,
i have created a report using ireport which contains arabic data.
when i execute the report from ireport to generate a pdf file it works.
however when i call this report from java i have an exception"
Could not create the report Could not load the following font :
pdfFontName : ARIAL.TTF
pdfEncoding : Identity-H"
the pdfFont i used it in ireport, also the pdfEncoding.
did anyone passed with the same problem
thanks for helpHello Oracle experts,
The parameters are getting passed successfully in my report.
But I want to know hous to use it in my query group.
I just want the syntax.
Thanks -
Curious thing while calling a procedure from Java !...
Hi !. My name is Agustin and my doubt would be the following one... I am working for a e-business comp and they asked me to call a procedure from java... The code is the following one:
CallableStatement cs = null;
System.out.println("Fecha Nro. 1: " + paramFechaDesde);
System.out.println("Fecha Nro. 2: " + paramFechaHasta);
try
cs = getDBTransaction().createCallableStatement("{call paq_w_ListadoSiniestralidadART. p_sinsiniest(?,?,?,?) }",0);
cs.registerOutParameter(4,OracleTypes.VARCHAR);
cs.setInt(1,paramContrato.intValue());
cs.setString(2,paramFechaDesde);
cs.setString(3,paramFechaHasta);
cs.setString(4,paramNombreArchivo);
cs.executeQuery();
String nomArchivo = cs.getString(4);
System.out.println("### " + nomArchivo +" ###");
catch(SQLException e)
The weird thing is that, I was expecting a big big exception but the only thing I got is
### Error ###
The String I am expecting is a file's name !; so I am a little bit confused...
Also I didn't know where to post so If it's in the wrong category... I apologize !... If anyone need more details, I'll be checking out... The account I am working on is an Insurance company, who is the one who provide access to the DB and the procedures... So I can't check what's inside...Please provide your Java and OS versions, the JDBC jar file and the Oracle DB version being used when you post.
>
I was expecting a big big exception
>
Then why do you have an empty exception block? That just makes it disappear so you won't see one if it happens.
And your code has
cs.registerOutParameter(4,OracleTypes.VARCHAR);
cs.setString(4,paramNombreArchivo);You use 'registerOutParameter' for an OUT parameter and the 'setXXX' methods for other parameters.
Remove the 'setSTring' for the OUT parameter.
Then as malcollmmc already said
>
Sounds like the PL/SQL is returning "Error" as the 4th parameter of the call
>
The actual value returned by PL/SQL is strictly determined by the PL/SQL code and Java and JDBC are not involved.
Fix the code problems, retest, and folllowup with whoever wrote the code if it still returns ERROR. -
ORA-00911: invalid character - Calling a function from Java..
Hi to all.. I have an issue when calling an oracle function from Java..
This is my Java code:
final StringBuffer strSql = new StringBuffer();
strSql.append("SELECT GET_TBL('II_2_1_6_5') AS TABLA FROM DUAL;");
st = conexion.createStatement();
rs = st.executeQuery(strSql.toString());
and in the executeQuery a SQLException is throwed:
java.sql.SQLException: ORA-00911: invalid character
I paste the query in TOAD and it works.. :S
anybody knows how can I solve this?Remove the Semicolon after Dual.
strSql.append("SELECT GET_TBL('II_2_1_6_5') AS TABLA FROM DUAL");
Sushant -
Is it possible to call ctx_doc.filter from Java?
Hello all,
Is it possible to call ctx_doc.filter from Java?
If so, do you have a code sample?
Thanks,
MarvinI have some Java code using ctx_doc.markup that can help:
try {
//make db conn
OracleCallableStatement stmt =(OracleCallableStatement)conn.prepareCall("begin "+
"ctx_doc.markup(index_name=>'text_idx', "+
"textkey=>?,"+
"text_query=>?,"+
"restab=>?,"+
"starttag=> '<a>',"+
"endtag=> '</a>' "+
"); " +
"end; ");
... // register other parameters
stmt.registerOutParameter(3, OracleTypes.CLOB);
stmt.execute();
oracle.sql.CLOB text_clob=null;
text_clob = ((OracleCallableStatement)stmt).getCLOB(3);
// read the CLOB by chunks
int chunk_size=text_clob.getChunkSize();
Reader char_stream = text_clob.getCharacterStream();
char[] char_array = new char[chunk_size];
for(int n=char_stream.read(char_array);n>0; n=char_stream.read(char_array)){
out.print(char_array);}
}catch (SQLException e) -
Calling ctx_doc.filter from java...is it possible?
Hello all,
Is it possible to call ctx_doc.filter from Java?
If it is possible, does anyone have a code sample they can share?
Thanks for the help,
Marvin
http://www.esenai.comI have some Java code using ctx_doc.markup that can help:
try {
//make db conn
OracleCallableStatement stmt =(OracleCallableStatement)conn.prepareCall("begin "+
"ctx_doc.markup(index_name=>'text_idx', "+
"textkey=>?,"+
"text_query=>?,"+
"restab=>?,"+
"starttag=> '<a>',"+
"endtag=> '</a>' "+
"); " +
"end; ");
... // register other parameters
stmt.registerOutParameter(3, OracleTypes.CLOB);
stmt.execute();
oracle.sql.CLOB text_clob=null;
text_clob = ((OracleCallableStatement)stmt).getCLOB(3);
// read the CLOB by chunks
int chunk_size=text_clob.getChunkSize();
Reader char_stream = text_clob.getCharacterStream();
char[] char_array = new char[chunk_size];
for(int n=char_stream.read(char_array);n>0; n=char_stream.read(char_array)){
out.print(char_array);}
}catch (SQLException e) -
How can I call ora:appendToList from java snippet?
I want to assign a list of user from User Task A to User Task B, but I don't know how to call ora:appendToList from java snippet, and are there any better ways to solve this situation?
Hi Rakesh,
Thank you for your help.
For issue 1, for example, user jcooper apply a vacation, and the request goes to his manager jstein,
and jstein dispatch the task to mtwain and rsteven for parallel approval, (this is just for example, in
some case, the manager can use the reassign function), so I use simple workflow pattern for manager approval,
and parallel workflow pattern for parallel approval, but in my situation, the user for parallel approval is
uncertain, need select by manager jstein, so I want to know how to assign the user from java code to bpel process.
The following is how I solve the problem now, put the user list string in flexString1 of simple workflow task,
then allocate the array for parallel assigneeUsers, then use setVariableData assign the value, it can do the job,
but the code is awful, I want to know how to do it in some better way.
<assign name="copyPayloadFromTask">
<copy>
<from expression="ora:countNodes( 'inputVariable','task','/task:task /task:assigneeUsers')"/>
<to variable="currentLength"/>
</copy>
</assign>
<sequence>
<bpelx:exec name="Java_Embedding_2" language="Java" version="1.4"><![CDATA[
Element ele=(Element)getVariableData("inputVariable","task","/task:task/task:flexString1");
String users=ele.getNodeValue();
String[] userArray=users.split(",");
setVariableData("arrayLength",new Integer(userArray.length));
]]>
</bpelx:exec>
<while name="While_1" condition=" (bpws:getVariableData('currentLength')) < (bpws:getVariableData('arrayLength')) ">
<assign name="Assign_1">
<copy>
<from expression="ora:appendToList('inputVariable','task',' /task:task/task:assigneeUsers', string( 'test'))"/>
<to variable="oraBPMTemporaryVariable"/>
</copy>
<copy>
<from expression="ora:countNodes( 'inputVariable','task','/task:task /task:assigneeUsers')"/>
<to variable="currentLength"/>
</copy>
</assign>
</while>
<bpelx:exec name="Java_Embedding_1" language="Java" version="1.4"><![CDATA[
Element ele=(Element)getVariableData("inputVariable","task","/task:task/task:flexString1");
String users=ele.getNodeValue();
String[] userArray=users.split(",");
for(int i=0;i<userArray.length;i++){
setVariableData("inputVariable","task","/task:task/task:assigneeUsers["+(i+1)+"]",userArray);
}]]>
</bpelx:exec>
Thanks,
Ming -
Calling javaFX script from Java program
I am trying to call JavaFX script from a simple Java program. code as follows:
import java.io.*;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class My{
public static void main(String[] args) {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("fx");
try {
InputStreamReader reader = new InputStreamReader(My.class.getResourceAsStream("first.fx"));
engine.eval(reader);
reader.close();
} catch (Exception e) {
e.printStackTrace();
my first.fx file code is here:
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
Stage {
title: "My First JavaFX Sphere"
scene: Scene {
width: 250
height: 250
content: [
Text {
font: Font { size: 24 }
x: 20, y: 90
textAlignment: TextAlignment.CENTER
content:"Welcome to \nJavaFX World"
} //Text
] // content
} // Scene
} // Stage
I am not able to run My.java. runtime error as follows:
java.lang.NullpointerException
Kindly correct me, where I am wrongI am able to call .fx file from Java. Thank you all for helping me to resolve this problem
Regards,
Ritu -
hello everyone
I have question
I need to call c program from java
I don't have problem with application or exe file in c it is working but when I call it from java it doesn't work there is no error but it doesn't work because when I execute the c program the black screen must be appeared so that I can enter the input file and then it produces the output file but in java I cann't see the black screen so please can you tell me the problem
I have used the following code to call c from java:
String line;
String output1 = "";
Process p = Runtime.getRuntime().exec("cpp.exe");
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output1 += (line + '\n');
input.close();Hi,
Try this in your code
p.waitFor();It is for waiting of the process till the completion of the I/O.
Regards -
Calling c function from java!!
hi all,
I want to call c function from java . I have gone through the link http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html for JNI.
According to this link we need to write the native method implementation in such a way that the method signature should exactly match the method signature created in the header file.
My problem is that i have a c application which i cannot modify in any ways i.e., i cannot change its code. But i want to call its function from my java code.
Please suggest me appropriate solution for this. Please let me know whether it can be done using JNI or is there any other method for this.
thanksThis link is amazing since those sources were wrote in 1998 and I started to develop JNative in 2004. I did not found them when I started.
Since JNative can deal with callbacks and probably COM in a near future, I expect to see it living to Dolphin at least.
--Marc (http://jnative.sf.net)
Maybe you are looking for
-
HP L7780 not scanning with Mac OS X 10.9.3
Upgraded MacBook operating system to OSX 10.9.3 and can no longer scan from HP L7780 All-in-One to computer? am I doing something wrong? or does this really not work anymore?
-
Transferring apps from my macbook pro to new macbook air
my old macbook pro froze. i bought a new macbook air and need to transfer my applications. How do I do that?
-
Global Variable declaration in Custom Infotype
Hi All, I need to validate a custom infotype field, where i need to check for execution times. I need to override the field value only during first time of the run(PAI logic) and there after user can choose a value of his choice. I was looking out fo
-
Logged into iChat, but buddy list isnt showing up.
Yesterday night, March 10, I logged onto iChat and my buddy list didn't show up. So i restarted my computer and nothing happened. Still no buddy list. I logged on to AIM and i got my buddy list to load. So is there anything i can do to get my buddy l
-
Steps SSIS and SSAS Migration from sql server 2005 to 2012?
steps SSIS,SSRS and SSAS Migration from sql server 2005 to 2012? any precautions to take while migration. any documentation or any specified steps.