How to call a function from a JAR file

Hi ALL,
I am trying to call a Public function from a JAR file from my JAVA
file. Can you please provide an example or suggest a good resource?
Basically my java file Test.Java should call a function called 'export_a_doc' from a JAR file Export.jar. How do I refer this in my Java file and call 'export_a_doc'?
Thanx

Hi,
HERE IS MY JAVA FILE
// We need this for Starting our Export Process
import com.newexport.Myclass;
public class MyTest {
     // Our function to Start Export
     protected static void test(String[] args) {
     System.out.println("Starting. \n---------------------");
     Myclass p = new Myclass();
     try {
p.Start_Export(args);
System.out.println("Finished. \n---------------------");
     } catch(Exception e) {
e.printStackTrace();
     public static void main(String[] args) {
     test(args);
HERE IS THE BATCH FILE TO BUILD AND RUN
cd \JNI\Srcs
echo "-------------"
c:\JBuilder7\jdk1.3.1\bin\javac -classpath C:\JNI\Export.jar MyTest.java
echo "-------------"
\JBuilder7\jdk1.3.1\bin\java.exe -classpath c:\JNI\Export.jar MyTest
The Export.jar uses other jar files
Raj

Similar Messages

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • How to call oracle function from ejb3

    i'm trying to call an oracle query-function from ejb3.
    The oracle function:
    create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
    RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
    m_sql VARCHAR2(250);
    BEGIN
    m_sql:='select count(thrId) from thread where secId='|| secid||'
    and thrAvai='|| avai;
    open cur for m_sql;
    return cur;
    END;
    I'v tried several ways to call it,but all failed:
    1. the calling code:
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");     
              query.setParameter(1, secId);
              query.setParameter(2, avai);
              return query.getSingleResult();
    but i got the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
    PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
    ORA-06550: row 1, col 7:
    PL/SQL: Statement ignored
    2. the calling code:
    @SqlResultSetMapping(name = "getSecThreadCount_Mapping")
    @NamedNativeQuery(name = "getSecThreadCount",
    query = "{?=call getSecThreadCount(:secId,:avai)}",
    resultSetMapping = "getSecThreadCount_Mapping",
    hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
              @QueryHint(name = "org.hibernate.readOnly", value = "true")})
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNamedQuery("getSecThreadCount");     
              query.setParameter("secId", secId);
              query.setParameter("avai", avai);
              return query.getSingleResult();
    but i run into the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
    By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
    Could anyone tell me how to call the function from EJB3?
    Thanks.

    Here's a working model:
    package.procedure: (created in example schema scott)
    CREATE OR REPLACE package  body data_pkg as
      type c_refcursor is ref cursor;
      -- function that return all emps of a certain dept
      function getEmployees ( p_deptId in number
      return c_refcursor
      is
        l_refcursor c_refcursor;
      begin
         open l_refcursor
        for
              select e.empno as emp_id
              ,        e.ename as emp_name
              ,        e.job   as emp_job
              ,        e.hiredate as emp_hiredate
              from   emp e
              where  e.DEPTNO = p_deptId;
        return l_refcursor;
      end getEmployees;
    end data_pkg;
    /entity class:
    package net.app.entity;
    import java.io.Serializable;
    import java.util.Date;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedNativeQuery;
    import javax.persistence.QueryHint;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @SuppressWarnings("serial")
    @Entity
    @Table (name="emp")
    @SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
    @NamedNativeQuery( name = "getEmpsByDeptId"
                   , query = "{ ? = call data_pkg.getEmployees(?)}"
                   , resultClass = Employee.class
                   , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
                          , @QueryHint(name = "org.hibernate.readOnly", value = "true")
    public class Employee implements Serializable
        @Id
        @Column(name="emp_id")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
        private int id;
        @Column(name="emp_name")
        private String name;
        @Column(name="emp_job")
        private String job;
        @Column(name="emp_hiredate")
        private Date hiredate;
        // constructor
        public Employee (){}
        // getters and setters
        public int getId()
         return id;
    etc...session bean:
    package net.app.entity;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    @Stateless
    public class ScottAdminImpl implements ScottAdmin
        @PersistenceContext
        private EntityManager entityManager;
        @SuppressWarnings("unchecked")
        public List<Employee> getEmployeesByDeptId(int deptId)
         ArrayList<Employee> empList;
         try
             Query query = entityManager.createNamedQuery("getEmpsByDeptId");
             query.setParameter(1, deptId);
             empList = (ArrayList<Employee>) query.getResultList();
             return empList;
         catch (Exception e)
             e.printStackTrace(System.out);
             return null;
    }client:
    package net.app.client;
    import java.util.List;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    public class ScottClient
        public static void main(String[] args)
         try
             // create local interface
             InitialContext ctx = new InitialContext();
             ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
             // select employees by deptno
             int deptno = 20;
             List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
             // output
             System.out.println("Listing employees:");
             for (Employee emp : empList)
              System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
         catch (NamingException e)
             e.printStackTrace(System.out);
    }Basically you just ignore the refcursor outbound parameter.
    This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
    Edited by: _Locutus on Apr 2, 2009 2:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to call a function from asp

    Hi!, I'd like to know how to call a function from an asp page. I've written:
    set rs = server.createobject("Adodb.recordset")
    rs.open "call dbo.sf_Obt_Des_Producto ('0000161')",Conn
    if err.description <> "" then
    response.write ("No se pudo! :(")
    else
    response.write ("rs: " & rs(0))
    end if
    rs.close
    set rs = nothing
    but there is an error:
    ORA-06576: not a valid function or procedure name
    Please is very urgent!!!
    Thanks.
    Angie.

    You need to use the syntax "{call <procedure_name>}".
    The {call } syntax tells the OLE DB provider that it needs to translate the call into whatever the database's procedure calling syntax is. This means that even though different databases have different syntax for calling stored procedures, your OLE DB code can be run against any of them without changing.
    Justin

  • Can Any one tell me what is the step in calling a function from a *.lib file in Labview application

    Hi, I am working on Labview 8.0.
    I am trying to  communicate to a thrid party HW using the driver file he has provided to me.
    The drive file is a *.lib file.
    I am unable to call the function from the lib file.
    I could get only from a DLL.
    Pls help .
    Regards
    -Patil

    patil wrote:
    When it is possible in Lab Windows, why calling a function from a static library is prohibited?
    I was trying to use Function node, but found that it is only for functions from a DLL file.
    Will CIN be useful.? 
    LabWindows is not the same as LabVIEW. LabVIEW cannot call .lib files. LIB files are intermediary products and you need to use a wrapper DLL that's compatible with the object format of the .lib file. It's as simple as that. LabWindows creates C application and from that perspective is no different than a regular C
    compiler. That's why you can call .lib files because that's how .lib
    files are used.
    A CIN, as pointed out, is something completely different and will not help you.  

  • How to call java function from PL/sql in oracle applications

    I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
    Thanks
    Kranthi

    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • How to call a function in one .js file from another .js file

    Hello Techies,
    I am trying to call a function in two.js file from one.js file.
    Here is my code
    one.js
    <script>
    document.write("<script type='text/javascript' src='/htmls/js/two.js'> <\/script>");
         function one()
                        var a;
                       two(a);
              }two.js
                  function two(a)
                          alert("two");
                      }But the function two() is not working.
    How can I do this one??
    regards,
    Krish

    I think there is a syntax error in line
    document.write("<script type='text/javascript' src='/htmls/js/two.js'> <\/script>");
    end tag <\/script> is wrong.

  • How to call  F4 functionality from R/3 to SRM

    hi,
    I need to call F4 functionality from R/3 field  "AFDAT" , to SRM field "INVDATE" .
    please suggest me  regarding this.The field is INVOICE DATE.
    Thanks&Reagrds,
    Basava Sridhar.

    Go to IMG > Define Backend Systems - and in entry for backend logical system add entry on the end of line in the second "RFC-Destination" field.
    Notice that RFC user in that conenction must not have SAP_ALL authorizations but per note 642202
    TIA
    Gordan

  • Can LabVIEW call a function from a .sys file or is LabVIEW limited to dll access?

    My vendor has sent me a .sys file with functions accessing their hardware.  Can i call these function from labview directly or do I have to wrapper the .sys with a dll?

    Well a sys file is a kernel device driver. LabVIEW does not have any direct way of accessing such a driver. The way kernel drivers are accessed is usually through a DLL which makes calls to WinAPI functions such as CreateFile(), ReadFile(), WriteFile(), CloseHandle() and DeviceIORequest(). Since these WinAPI calls are basically just DLL calls too, you could theoretically use the Call Library Node to call them and access the kernel device driver in such a way.
    However for any kernel device driver with more than one or two device driver calls, it will certainly be easier in terms of development, debugging and maintenance of the code, to write actually a dedicated DLL in C/C++ for this device driver and access that DLL from LabVIEW, especially if you consider the LabVIEW datatype limitations when designing the DLL interface (Basically this same DLL can then be called from any other Windows development environment, be it Visual Basic (similar datatype limitation as LabVIEW), Delphi, (Visual) C, LabVIEW or also various scripting environments like Python and Lua.
    Some of the necessary WindAPI calls are rather involved and pose quite a bit of trouble to get the parameter data right in LabVIEw.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to combine the classes from 2 jar files into 1?

    Hi there
    I have got 2 jar files with the same name but the classes that they contain are different. So, I want to combine those 2 files into 1. Could anyone please tell me how to add the classes in a jar file to another jar file?
    Thanks for your help!
    From
    Edmund

    The jar utility allows you to extract files as well as put them into a jar. This is in the java docs.
    You might have to hand modify the manifest file if it was hand modified in the first place. All you should have to do is copy the text from one file to another. The manifest will have the same name so you will have to extract to different dirs so it isn't overwritten.
    Steps:
    -Create dir1 and dir2
    -Extract jar1 into dir1, Extract jar2 into dir2.
    -Manually examine manifests and combine if needed.
    -Copy files from one dir to another.
    -Use jar tool to create new jar.

  • How to call C functions from native functions?

    Hi, I want to call a C function from a JNICALL?
    i wrote somthin like this:
    #include "ParamInput1.h"
    #include <jni.h>
    #include <stdio.h>
    #include "testPhase1.h"
    JNIEXPORT void JNICALL
    Java_ParamInput1_phase1(JNIEnv *env,
                   jobject obj,
                   jdouble tSim,
                   jdouble tSup,
                   jdouble iSim)
    double threshSim = tSim;
    double threshSup = tSup;
    double itemSim = iSim;
    /* call test Phase1 to execute the function*/
    testPhase1(threshSim, threshSup, itemSim);
    return;
    And I always get "undefined symbol: testPhase1__Fddd" error!
    what is the problem here? thanks alot!
    Jim

    Basically - you are already are compiling a c file. Replace that c file with all the c files.
    Specifically it depends on the OS, compiler and how you are compiling
    For windows add it the project or compile each file and then add the object fill to the link line.
    For unix add the other c files in to the compile line the same place you have the current C file.

  • How to call a function from Java to JSP

    Hello,
    I have a question about using tags.
    I have a java file,which has a function. Now I want to call this function into my JSP page.
    I'm using JSP 1.2 and TOMCAT 4.1 with Java2 SDK.
    I search through the web and find a method to do this.Bu it requires JSP 2.0
    But I try that in my machine(using JSP 1.2).It gives an error:
    Did you know what is the error? Or is there any method to call a function into my JSP page?
    Please, help me to solve this.
    Here are my codes(part of them)
    UserPassword.java file
    package data;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class UserPassword
         public static String verify(String username,String password){
              // some codes
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
            PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
         "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
      <tlib-version>1.0</tlib-version>
      <jsp-version>1.2</jsp-version>
      <short-name>simple</short-name>
      <uri>http://jakarta.apache.org/tomcat/HRM/WEB-INF/lib</uri>
      <description>
         A  tab library for the login
      </description>
    <function>
            <description>verify username and password</description>
            <name>verify</name>
            <function-class>data.UserPassword</function-class>
            <function-signature>String verify(java.lang.String,java.lang.String)
            </function-signature>
    </function>
    </taglib>I put this file into the webapps/HRM/WEB-INF/lib folder
    Here is my JSP file.
    <%@ page language="java" %>
    <%@ page import="data.UserPassword" %>
    <%@ page session="true" %>
    <%@ taglib prefix="login" uri="/WEB-INF/lib/LoginVerify.tld" %>
    <jsp:useBean id="useraccount" class="data.UserPassword"/>
    <jsp:setProperty name="useraccount" property="*"/>
    <%
    String status = UserPassword.verify(String username,String password);
    String nextPage = "MainForm.jsp";
    if(status.equals("InvalidU")) nextPage ="InvalidUserName.jsp";
    if(status.equals("InvalidP")) nextPage ="InvalidPassword.jsp";
    if(status.equals("main")) nextPage ="MainForm.jsp";
    %>
    <jsp:forward page="<%=nextPage%>"/>
    Here is the error:
    org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/lib/LoginVerify.tld: (line 18, col -1): Element "taglib" does not allow "function" here.
         at org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:189)
         at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:247)
         at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:183)
         at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:354)
         at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:381)Please, help me to solve this trouble.
    Thanks.

    Yes. As serlank showed, you can just call the function easily in scriptlet tags
    However the whole point of a tag library is to avoid the use of scriptlets.
    Seeing as you can't use functions, is just to do it as a standard tag.
    ie in your jsp
    <login:verify name="<%= userName %>" password = "<%= password %>" resultVar = "status"/>
    <c:choose>
      <c:when test="${status == 'InvalidU'}">
        <c:set var="nextPage" value="InvalidUserName.jsp"/>
      </c:when>
      <c:when test="${status == 'InvalidP'}">
        <c:set var="nextPage" value="InvalidPassword.jsp"/>
      </c:when>
    </c:choose>In your case, this tag in the tld would possibly look something like this.
    You would then have to write a tag handler class that would call the function you want.
    <tag>
      <name>verify</name>
      <tagclass>com.tags.login.Verify</tagclass>
      <teiclass>com.tags.login.VerifyTEI</teiclass>  (if required)
      <bodycontent>JSP</bodycontent>
    // name attribute 
    <attribute>
          <name>name</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
        </attribute>
    // password attribute
        <attribute>
          <name>password</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
        </attribute>
    // result variable to return a response from the tag.
      <variable>
        <name-from-attribute >resultVar</name-from-attribute >
        <variable-class>java.lang.String</variable-class>
        <declare>true</declare>
        <scope>AT_END</scope>
      </variable>
    </tag>Hope this helps some, and doesn't confuse too much :-)
    Cheers,
    evnafets

  • How to call JSP function from onClick Action

    Hi
    I am trying to call a jsp function, onclick of a checkbox. This jsp function will in turn connect to the database and gets related information. I dont want to submit the data inorder to avoid posting and getting of huge data. Is there a simple way to call a jsp function from the users onClick action.
    Appreciate anyones help!!!
    Thanks alot
    Joe

    So, i have to submit the form to call the jsp function. Basically yes.
    Sorry for the shortness of the answer, but I am pretty sure we have had this conversation (or one very much like it) before.
    Java/JSP runs on the server, generates an html page, and stops running.
    Javascript runs on the client in the web browser, once the page is loaded.
    You cannot call java code from javascript.
    The only way you can run java code again is to make a request - either by submitting a form, or clicking a link.
    If you don't want to refresh the current page, you CAN get tricky with javascript and multiple frames. You submit to another frame, and when it loads, it uses javascript onload event to call back and modify the main frame. Its tricky to get going, and very easy to break, so I don't normally recommend it.
    Good luck,
    evnafets

  • How to Call a function from FMS to AS3

    Hi,
    I am using Windows operating system, Flash CS3 and FMS 3.5.
    I am new to Action Script 3.0 But I am good in Action Script 2.0.
    I am trying to call a function declared in Action Script 3.0
    from FMS. here I have declared it as follows.
    In FMS I am calling a function as
    application.onConnect(client){
    client.call("informServer");
    In Flash AS 3 I have declared this function as follows.
    var nc = new NetConnection();
    // Now here I declare function
    nc.addEventListener("informServer", informServerHandler);
    nc.connect("rtmp://localhost/abc");
    private function informServerHandler(evt){
    trace(" Till here Done ");
    So When I execute Flash file then it connects to FMS and also
    in NetStatus event of NetConnection I got Connected.
    But Then I got Error in Flash as
    Error #2095: flash.net.NetConnection was unable to invoke
    callback informServer." error=ReferenceError: Error #1069: Property
    informServer not found on flash.net.NetConnection and there is no
    default value.]
    Please tell me Have I not declared the Function in AS 3
    properly or I am doing something wrong. Please Some one help me...
    Thanks in advance.

    You can't add an event listener, as your custom method is not
    a method of the NetConnection class. Instead, you can assign
    methods to the NetConnection's client property:
    nc.client.informServer = function(){
    // do something
    If you want to just define your functions in a class, you can
    make the class the value of nc.client:
    class blah{
    function blah(){
    var nc:NetConnection = new NetConnection()
    nc.client=this;
    //connect, status listener, etc
    private function informServer(){
    // Now this function is invoked, since the class is the
    NetConnection's client.
    }

  • How to call a function from one viewmodel to another viewmodel

    Hi ,
    How to call a funtion of another viewmodel in a viewmodel . This help would be much appreciated
    Thank You
    Jeevan Vinay

    Please close your previous threads by marking helpful posts as answer before you start a new one.
    You need to either get a reference to the second view model from the first one or you could use some kind of messenger or event aggregator to pass a message from the first view model to the second one. The latter approach is preferable as it doesn't create
    a tight coupling between the two view model classes.
    Please refer to my blog post for more information and an example of how to use Prism's EventAggregator to do this:
    http://blog.magnusmontin.net/2014/02/28/using-the-event-aggregator-pattern-to-communicate-between-view-models/
    You will need to download and install Prism to be able use the EventAggregator class:
    https://www.nuget.org/packages/Prism/
    Another popular framework out there is the MvvmLight which contains a Messenger class that works pretty much the same. Andy has provided and example of how to use this one:
    http://social.technet.microsoft.com/wiki/contents/articles/26070.communicating-between-classes.aspx
    You can download and install MvvmLight via Nuget (Tools->Nuget Package Manager->Package Manager Console in Visual Studio):
    https://www.nuget.org/packages/MvvmLight/
    Please remember to close your threads by marking all helpful posts as answer and then start a new thread if you have a new question.

Maybe you are looking for