Linux system call used in process creation from java?
Does Runtime.getRuntime().exec("some command"); bottom out in vfork, fork or something else on Linux versions of the java 1.5 jdk?
If the second, get the VM source and look. Or run a test case using the system call tracing utility "strace".
Similar Messages
-
Internal system call used by "ps" command
Hi All,
Can any one let me the internal system call used by "ps" command to retrieve the process information. I want to use the same system call in my program to get list of information about processes currently running in the system. I do not want to use the "ps" command in my code.Justin_Samuel wrote:
Hi All,
Can any one let me the internal system call used by "ps" command to retrieve the process information. I want to use the same system call in my program to get list of information about processes currently running in the system. I do not want to use the "ps" command in my code.You can access the /proc filesystem for getting information about
processes, even more than is available via ps.
Have a look at:
man -s 4 proc -
Calling native Objective C code from Java Script
Hi,
I want to call native objective C code from Java script.
I know one way by using : webView:shouldStartLoadWithRequest:navigationType
Is there another way of doing same?
Thanks,
Ganesh Pisal
Vavni IncAre any of those threads calling java code? If yes then are you calling the Attach method?
-
Calling a PL/SQL function from java
I would like to call a pl/sql function from java. My pl/sql function is taking arrays of records as parameters. How do i proceed? Which specific oracle packages do I have to import?
Please send an example.
TIA,
Darko GuberinaDocumentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
says JPublisher can publish records too.
But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
PACKAGE "COMPANY" AS
type emp_rec is record (empno number, ename varchar2(10));
type emp_list is varray(5) of emp_rec;
type factory is record (
name varchar(10),
emps emp_list
function get_factory(p_name varchar) return factory;
END;
then I see <unknown type or type not found> at sql or java files generated. Any ideas? -
Making Palm System calls using J2ME
Hi is there anyway where I can use the old KJava API or even the J2ME to make system calls such as
DmFindDatabase(0,"Something")
SysAppLaunch(0,dbID,0,cmdPrintChars,theChars,&result);
axlrose82[axlrose82],
At the moment, we are quite certain that the kVM for the PalmOS do not contain any API that allows a developer to make system calls to the PalmOS itself. The CLDC/MIDP specification does not specify any native system calls access any of the native apps. I can see from your code that you are trying to access the Palm database but I'm afraid you are out of luck with the current specs.
HTH.
Allen Lai
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/ -
Hi!
Can anyone tell me how to do Unix System Calls in my Java program?
If possible please give me the java code for it taking one unix system call as an example.
Thanks in advance
Rajdo you mean firing off a shell command, or making actual kernel API calls or C library calls?
for shell commands, have a look at Runtime.exec(). for kernel calls, use JNI. the JNI FAQ mentions something called "shared stubs" that may be of use:
http://java.sun.com/products/jdk/faq/jnifaq.html
cheers,
p -
Calling a third Party dll from java using JNI
Hi
I want an immediate help from u all.
I have athird party c dll with .h and .lib file
I wont be able to cahnge any thing in those files.
I want to call the functions of that from my Java code.
Ist possible to call the dll without writing any c or c++ wrapper over it?if yes , how to do it?Hi,
You may use a generic wrapper like JNative.
Commercial wappers also exists.
--Marc (http://jnative.sf.net) -
Call Windows COM/DCOM objects from Java on Linux
Hello, is it possible to call COM/DCOM objects running on Windows from Java on Linux machine? Thank you.
I don't know anything about it but it looks like EZ JCom in conjunction with the included Remote Access Service does what you're after. It's not free though.
http://www.ezjcom.com/ -
Call an interactive UNIX command from java
Hi,
I want to call a UNIX command from java. When issue the command 'htpasswd -c filename username' on UNIX terminal, it asks for the new password and the then confirmation password again (yeah, unfortunately the htpasswd installed on our system does not allow you proivde the password on the command line. So have to work interactively ). Now, I have written a simple java program RunCommand.java. I am hardcoding the password for the htpasswd command in the file (in the real situation, password will be generated dynamically). I want to issue 'java RunCommand' on the UNIX command line and get back the command prompt without being asked for the password twice. The code is below, but the Outputstream does not work as expected. It always asks for inputs. Any idea? Many thanks.
import java.io.*;
public class RunCommand {
public static void main(String args[]) throws Exception {
String s = null;
try {
String cmd = "htpasswd -c filename username ";
// run a Unix command
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
OutputStream stdOut = p.getOutputStream();
String pswd = "mypassword";
while ((s = stdInput.readLine()) != null) {
s = stdInput.readLine();
stdOut.write(pswd.getBytes());
stdOut.flush();
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
stdOut.close();
stdInput.close();
stdError.close();
System.exit(0);
catch (IOException e) {
System.out.println("exceptions caught: ");
e.printStackTrace();
System.exit(-1);There are only about 9 billion responses a day on how to do this. Use the search feature.
-
Calling stored procedures in Sybase from java
Hi,
I am using the following stored procedure in Sybase
use xyzdb
go
-- drop procedure if it already exist
if object_id('up_name_select') is not null
begin
drop procedure up_name_select
end
go
create procedure up_name_select
@zid numeric(7,0),
@firstname char(40),
@lastname char(40)
as
select zid,
firstname,
lastname
from name
where zid = @zid or
(lastname like @lastname or firstname like @firstname)
go
-- update documentation records in object_docs
delete object_docs
from object_docs
where object_name = "up_name_select"
go
insert into object_docs values("up_name_select","Selects records from the name table based upon the values of the input parameters.")
go
-- update documentation records in column_docs
delete column_docs
from column_docs
where object_name = "up_name_select"
go
insert into column_docs values("up_name_select","@zid","System generated ID for an individual contact.")
insert into column_docs values("up_name_select","@firstname","First name of the contact. SQL wild card characters are accepted.")
insert into column_docs values("up_name_select","@lastname","Last name of the contact. SQL wild card characters are accepted.")
go
-- print success message and grant permissions
if object_id('up_name_select') is not null
begin
print "Procedure up_name_select created."
grant execute on up_name_select to developer_role
end
go
This stored procedure selects the values from the table "name" for a given where condition (if I am not wrong).
Can any one give me sample java code to select the records from the table "name" for a given zid.
Thankyou in advance.
Regards
sgatl2calling stored procedures from java
here is the sample code
CallableStatement cs = con.prepareCall("{call selectlogin (?)}");
cs.setString (1, "value");
ResultSet rs = cs.executeQuery ();
while (rs.next ())
//your code for display
} more on gooooooogle
http://www.google.com/search?q=calling+stored+procedures+from+java+with+sample+example&client=netscape-pp&rls=com.netscape:en-US -
Call stored function / stored procedure from JAVA/JPA and pass array
I fail calling a plsql function from java with jpa - it works perfect without the array but its not working with the array:
PLSQL Function:
function getHtml(pWhere VARCHAR2 DEFAULT NULL,
pColSort HTP.STRINGARRAY) return clob is
begin
errorhndl.Log(pMessage => 'called');
htp.prn('das ist der test
for i in 1 .. pColSort.count loop
htp.p('
pColSort['||i||']: '||pColSort(i));
end loop;
htp.prn('
<table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
htp.prn('test ende');
return htp.gHtpPClob;
exception
when others then
null;
end getHtml;
PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
type STRINGARRAY is table of varchar2(256) index by binary_integer;
JAVA DOA:
public class ShowReportDOAImpl implements ShowReportDOA {
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall procShowReport;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
.withCatalogName("Show_Report")
.withFunctionName("getHtml")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(
new SqlParameter("pWhere", Types.VARCHAR),
new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
new SqlOutParameter("RETURN", Types.CLOB)
public String readReport(Long id, ParameterHelper ph) {
String[] sortCol = {"max", "michi", "stefan"};
String pWhere = "fritz";
MapSqlParameterSource parms = new MapSqlParameterSource();
parms.addValue("pWhere", pWhere);
parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
Clob clob = procShowReport.executeFunction(Clob.class, parms);
String clobString = "";
try {
System.out.println("length: "+new Long(clob.length()).intValue());
clobString = clob.getSubString(1, new Long(clob.length()).intValue());
} catch (SQLException e) {
e.printStackTrace();
return clobString;
EXCEPTION IS:
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
Please help!!
Please help!!user8374822 wrote:
PLSQL Function:
function getHtml(pWhere VARCHAR2 DEFAULT NULL,
pColSort HTP.STRINGARRAY) return clob is
begin
end getHtml;
PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
type STRINGARRAY is table of varchar2(256) index by binary_integer;
JAVA DOA:
new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),I don't know much (??) java and can't understand your error messages as they are not in english.
But I have a feeling that the error is because either
a) "Types.ARRAY" in Java world probably does not map to an index-by table in oracle or
b) the array must be created as a SQL TYPE and not as a package variable or
c) both of the above
You may want to try following approaches
1) Change the array type declaration to nested table i.e. use "type STRINGARRAY is table of varchar2(256)"
2) If the above does not work, then create a sql type (using CREATE TYPE statement) to create STRINGARRAY as a SQL type of varchar2(256)
Hope this helps. -
How to call sql procedure with parameter from java
Hello,
i am trying to call one sql procedure with two parameters from java.
the first parameter is In parameter, the second is OUT.
the return value of this java method should be this second parameter value.
the following is my java code:
protected String getNextRunNumber() {
String runnumber=null;
String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
CallableStatement state = null;
try{
Connection con= getDatabaseConnection();
state = con.prepareCall(sql);
state.setString(1, m_appKeyExport);
state.registerOutParameter(2,Types.NUMERIC,0);
state.execute();
ResultSet resultR = (ResultSet)state.getObject(2);
while (resultR.next()) {
runnumber=resultR.getBigDecimal(1).toString();
catch (SQLException e){System.out.println("You can not get the export next run number properly");}
return runnumber;
i got error message like:
java.lang.ClassCastException: java.math.BigDecimal
As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
Please help me to solve this problem.
Thanks a lot.state.execute();
i try to use debug to find the problem, in this line, i saw
OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
is this the problem? -
How to make system call to execute command line in JAVA?
Hi,
I am new in JAVA. How to make system call to execute the following command line in JAVA in LINUX environment.
rpm -qa jdkIn C programming, use as such:
system ("rpm -qa jdk");
How about JAVA?
Thanks.Runtime.getRuntime().exec. But first read this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
Call native function fflush & strprn from java
Hi,
I need to call a native function fflush and stdprn from java for printing a file.
How can i call this function?
Can any one help me with sample code.
Thanks,
rpalaniveluThanks your reply,
Actually my problem is need to take printout using dot matrix printer(text printer) with different font size.
So, i am using native method which is available in c.
in c program i am using fflush,stdprn and fprintf.
Here i've attached my sample program also.
#include <jni.h>
#include "NativePrint.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXLINE_LEN 100
JNIEXPORT jint JNICALL
Java_NativePrint_dotMatrixPrint(JNIEnv* env, jobject obj )
FILE *fp;
char filename[20];
char line[100]; /* A line read from the file */
int lineNumber = 0;
/* Print control codes */
char boldOn = 14;
char boldOff = 20;
char contentlenOn = 15;
char contentlenOff = 18;
printf("Printing from C3");
strcpy( filename , "sayHello.c" );
/* Open the file in read mode */
fp = fopen( filename , "r" );
/* Error in opening file, then exit */
if ( fp == NULL )
printf( "\nERROR: %s cannot be opened\n" , filename );
exit( 1 );
while ( fgets( line , 100 , fp ) != NULL )
lineNumber++; /* Line we are about to process next */
printf("%s",line);
/* If this is the first line */
if ( lineNumber == 1 )
/* then print it in bold */
//fprintf( stdprn , "%c" , boldOn );
fprintf( stdprn , "%c" , contentlenOn );
fprintf( stdprn , line );
fprintf( stdprn , "%c" , contentlenOff);
//fprintf( stdprn , "%c" , boldOff );
else
/* else print it in normal mode */
fprintf( stdprn , line );
fflush(stdprn);
return 0; -
Calling a COBOL stored proc from Java Servlet
I am trying to call a COBOL stored proc from a Java Servlet. The stored proc is stored on a DB2 database. I need to send 6 inputs to the COBOL stored proc and the output will be the return code of the stored proc. I'm not sure if I'm going about this the right way. This is how my code looks...
public int callStoredProc(CallableStatement cstmt,
Connection con,
String sYear,
String sReportNbr,
String sSystemCode,
String sUserId,
String sModuleNbr,
String sFormId){
int iParm1 = 0;
try{
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
catch(ClassNotFoundException ex){
System.out.println("Failed to locate database driver: "
+ ex.toString());
return iParm1;
try{
cstmt = con.prepareCall("{? = CALL MKTPZ90C
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.setString(2, sYear);
cstmt.setString(3, sReportNbr);
cstmt.setString(4, sSystemCode);
cstmt.setString(5, sUserId);
cstmt.setString(6, sModuleNbr);
cstmt.setString(7, sFormId);
cstmt.execute();
iParm1 = cstmt.getInt(1);
CloseSQLStatement(cstmt);
catch(SQLException ex) {
CloseSQLStatement(cstmt);
System.out.println("SQL exception occurred:" +
ex.toString());
return iParm1;
return iParm1;
Could someone tell me if this is the right way to go about doing this?
Thanks!!!!!!I didn't see the code where you create the database connection (variable "con"). However, the answer to your question "Is this the right way...", for me, is "Anything that works is the right way." So try it. That's a first approximation, but once you have something that works you can start on improving it, if that becomes necessary.
Maybe you are looking for
-
Requested resource is not available
I asked this question in the forum before. And I have followed up the messages with regard to the same problem experience by one of the forum members here. Hence I apologize if i am posting this again. This is with regard to the bookstore tutorial of
-
BICatalog objects in Webcenter Composer not getting added 2 page
Scenario: OBIEE 11g integration with Webcenter portal page. We are trying to integrate BI Composer to ADF Page for an urgent customer requirement. The BI Objects are getting displayed in webcenter catalog. But the dasboard objects when added to ADF p
-
Outlook integration Add-on is not working SAP 2007B (Status - Failed)
Dear B1 Experts, Please let me know what should i do , as SAP B1SAP 2007B Add on Outlook integration version 8.00.01.07 is having status as Failed ( it is not working ) So what should i do now?? Should i reinstall if yes then how to go about it?? plz
-
Hi, Can somebody explain me about the basics of tuning or any good resource online for absolute beginners. Concepts of Explain Plan, Hints, indexes etc... I ve come across some terminolgy like, Driving table, The order of the table in the from clause
-
Problème installation Photoshop
Bonjour, J'ai téléchargé la version d'essai de Photoshop mais lors de l'installation, celle-ci reste bloquée sur le message "tentative de connexion au serveur"... Merci de votre aide. Cordialement,