How do I call a function in java?

I'm calling a function called lightParse() from the method. But, I'm getting an error:
F:\Data>javac -classpath xerces.jar;xalan.jar;classpath%; Test.java
Test.java:22: lightParse(java.lang.String) in Test cannot be applied to ()
lightParse();
^
The scenario or code portion is :
import javax.swing.*;
import java.awt.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class Test extends JFrame
     JList list;
     JScrollPane listContainer;
     public Test()
          setSize(300, 300);
          setVisible(true);
          initialize();
          lightParse(); // calling the function
     public void initialize()
          list = new JList(new DefaultListModel()); // Set the initial model
          listContainer = new JScrollPane(list);
          listContainer.setSize(new Dimension(200, 200));
          getContentPane().setLayout(new BorderLayout());
          getContentPane().add(listContainer, "Center");
          validate(); // Validate the screen
// The function is the following
     public void lightParse(String url)
          DocumentBuilder parser;
          DocumentBuilderFactory factory =
                    DocumentBuilderFactory.newInstance();
          try {
                    parser = factory.newDocumentBuilder();
                    Document doc = parser.parse(url);
How do I call the function correctly with the right parameter?
Thanks in advance for the answer.

u r calling lightParse method without passing the expected "String" argument. There must not be an overloaded method for lightParse without any arguments.
So u should use this:
lightParse(some string here);
Hope this explains.
I'm calling a function called lightParse() from the
method. But, I'm getting an error:
F:\Data>javac -classpath
xerces.jar;xalan.jar;classpath%; Test.java
Test.java:22: lightParse(java.lang.String) in Test
cannot be applied to ()
lightParse();
^
The scenario or code portion is :
import javax.swing.*;
import java.awt.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class Test extends JFrame
JList list;
JScrollPane listContainer;
public Test()
setSize(300, 300);
setVisible(true);
initialize();
lightParse(); // calling the function
public void initialize()
list = new JList(new DefaultListModel()); // Set the
e initial model
listContainer = new JScrollPane(list);
listContainer.setSize(new Dimension(200, 200));
getContentPane().setLayout(new BorderLayout());
getContentPane().add(listContainer, "Center");
validate(); // Validate the screen
// The function is the following
public void lightParse(String url)
DocumentBuilder parser;
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
try {
parser = factory.newDocumentBuilder();
Document doc = parser.parse(url);
How do I call the function correctly with the right
parameter?
Thanks in advance for the answer.

Similar Messages

  • Calling c functions in java

    How do I call c functions from java?

    See http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • ADF: Can i call javascript function from java clsss method in ADF?

    Hi,
    I want to call javascript function in Java class method, is it possible in ADF? , if yes then how?
    or I need to use Java 6 feature directely?
    Regards,
    Deepak

    private void writeJavaScriptToClient(String script)
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
    erks.addScript(fctx, script);
    }usage
    StringBuilder script = new StringBuilder();
    script.append( "var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');");
    script.append("if(popup != null){"); script.append("popup.show();"); script.append("}");
    writeJavaScriptToClient(script.toString());Timo

  • How can I call a function from a procedure

    I have a function named: f_calc_value which return the variable v_result. This function is part of a package.
    How can I call this function from a new procedure I am creating?
    Thanks

    or refer this theread....calling function from procedure

  • How do you call a function within a package using OCI in C

    I am trying to call a user-defined function in Oracle 8.1.7 using OCI in C. I am getting a ORA-06550 PLS-00221, <function name> is not a procedure or is undefined. Can anyone tell me how I would call a function using OCI?
    Thanks.

    I think I figured it out, but I am now getting a ORA-06512 error; numeric or value error: character string buffer too small.

  • How do you call a function in an attached MovieClip from the current MovieClip?

    Hi there,
    I have this MovieClip A (converted as a symbol) and put in my
    main MovieClip B using attachMovie() , and I am wondering how I can
    call a function defined in A from within B.
    Is it possible?
    Thanks

    Hi kglad,
    yes, I did the attachMovie of the symbol B and it seems like
    none of the ActionScript written in B was not carried over.
    This is how I built B into a symbol :
    (1) Two layers ( one for the ActionScript only, the other for
    the Components)
    (2) I defined the functions to be called remotely by A in the
    ActionScript layer
    (3) I selected all the components in the Components Layer and
    did a Convert To Symbol
    (4) I added the Symbol into A's Library
    (5) I used attachMovie to instantiate the Symbol of B
    I must have missed out something somewhere
    Thanks

  • Calling C++ functions by Java via CORBA?

    Hello,
    I am interested in source code examples of calling C++ functions by Java via CORBA. For example the client is in Java and the server is in C++. Is it posible that the IDL compiler can generate "java" client stubs and "c++" server sceleton? So the implementation of the client will "inherit" the stubs generated by the IDL compiler, and the server implementation will use the sceleton.
    Thank you in advance.

    As far as I know, you've got to have your idl on both side. You compile idl mapping to java on client side and mapping to C++ on server side. Then you should be able to do it.
    Kim

  • Call DLL function from JAVA

    HI!
    What's the best way (and simple) to call DLL function from JAVA.
    DLL function (developed in C) has two input parameters (string) and return an integer.
    Could you help with an example?
    Thanks a lot.

    Do a google search for 'JNI tutorial' and it will turn up hundreds of examples.

  • 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.
    thanks

    This 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)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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 access C/C++ functions in Java using existing .dll library

    Hi JNI Guru's,
    I am having well written API in C/C++.This C/C++ files are made into *.dll files.The api are working fine.
    I wan't access the C/C++ api functions in Java., just using System.LoadLibrary("*.dll").Is it possible.I kindly request you to suggest some examples and how to do this.
    Its Urgent !.
    Thanks and Regards,
    V K LAL

    In general you cannot simply access dlls that have already been written. The DLLs called using JNI must conform to JNI calling standards.
    This means you will probably have to write one or more "wrapper" dlls which a) provide the correct JNI interface, and b) call the existing dlls.
    There are some programs around that claim to be able to generate such wrappers. Try a google search for "wrapper", "jni", "generate".
    The JNI tutorial covers creating wrappers.

  • Calling c++ function in java

    Hi,
    I would like to know how I can modify c++ program so that I can use its(c++) functions in java.
    the program is c++ ready-made and i would like to use its functions in a java package.
    i read the turiols concerning this on java.sun.com but does that mean that i have append "jni.h", "JNIEXPORT", etc to the c++ file?
    Hints shall be appreciated.
    Thanks.

    OK, thanks.I have tried the jni procedure but without success.
    Is it possible for Java talk to native code (c++) via TCP/IP.
    Please advice of any links/knowledge.
    Thanks.
    1. Strictly speaking, java does not operate on C++; it
    operates on C functions. This is more than a quibble:
    o JNI expects to call C functions, not methods of C++
    objects.
    o In fact, if you really just have functions, but they
    are compiled as C++, then you will probably have to
    declare C linkage.
    2. Functions called from java must conform to JNI
    calling conventions.
    o In general, the starting point is to define how you
    would like the object and native method to look in
    java, then run jni.h to generate the appropriate C
    header definitions, then write the C code.
    o Functions called from java must exist in shared
    libraries - on Windows, in dlls.
    o Existing C function libraries are typically accessed
    by writing a "wrapper" dll that implements the
    required java interface and then calls the existing
    library functions.
    o In fact, a wrapper could actually instantiate C++
    objects and call their methods.
    3. You might care to look up something called JACE,
    which some people claim can generate the kinds of
    wrappers discussed here.

  • 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

  • How do i call a function within the jsp?

    Hi,
    What i am doing is now allow a user to type in comment and when the user click on "Add" button, it will call my function and write to a txt file.How can i call a custom jsp function within my jsp page or what is the correct way to do this?
    [My current codes]
    <form name="SubmitEvent" method="post" action="addComment()">
    </form>
    function addComment()
    System.out.println("Entered Add Comment function");
    Thanks for your help!

    You can define a Java Bean (I presume you know the rules to write a Java Bean) and send the read value as parameter to the Bean and then call a function in the Bean from the JSP.
    Contact me if you need more help!

  • Call C function from Java

    Hi
    How do I call a C function from a java applet. Any ideas.
    Thanks
    Jay

    How do I call a C function from a java applet.
    You're going to run into problems here even after you figure out all the JNI details. Loading a shared object from an applet violates the security model - you will have to sign the applet. In addition, to be cross-platform (I'm using linux now), you will have to provide multiple dll/so - one for each architecture...

Maybe you are looking for

  • Moving data from pc to mac

    so im switching from pc to mac(made a post earlier with some questions) and have another question regarding moving my data. although i could use an ipod with disk enabled, could i also just use an external hardrive? my plan was to borrow my friends e

  • htmlb:fileUpload in BSP

    Hi, Iam uploading an Excel file from the local PC using the <htmlb:fileUpload> I wanted to read this uploaded file and create a document with the data in the cells on the excel. When iam trying to read i get the data in numbers. any ideas to read the

  • Somehow ASK now comes up on every search, How do I get rid of it?

    i KEPT GETTING A MESSAGE THAT SOME SECURITY ISSUE NEEDED UPDATING. WHEN I ALLOWED IT TO MAKE CHANGES IN MY PC. AND RETURNED TO FIREFOX NOW ANY SEARCH I MAKE THE ASK TOOL BAR APPEARS

  • Leopard install quitting

    Hi, I have tried to install Leopard from an original DVD, from an image on an external FW drive and from a copy of the install DVD. In all cases the media checks out ok but part way through the install the install fails (at this point doing a clean i

  • Non-updating desktop - hidden icons

    This has been baffling me for ages. A quite normal OS X install. If I save files or copy files to my desktop, I often don't see them until I reboot, or it does some background refresh. If I go to finder, I can sometimes see them, and if I go to Spotl