How to include built in classes..?

hi friends i am having the doubt in mind,I need to use linked list in my program can i import the linked list class before i use (or) shall i directly include in the code.It means...
import java.util.LinkedList;
class A
or class A
java.util.LinkedList a=new java.util.LinkedList();
I want to knw which one is better...?and anyone tell me the reason...?Thanks in advance

import java.util.LinkedList;
class A
or class A
java.util.LinkedList a=new
java.util.LinkedList();The .class files generated for the two cases will be identical. Importing has NO effect at runtime. All it does is tell the compiler, "When I say List I mean java.util.List," which saves you some typing and keeps your code less cluttered. Either way, the compiler generates a fully-qualified reference to java.util.List in the class file.

Similar Messages

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

  • How to include Managed bean class in build sciprt for taskflow (Jdev 11.4)

    Hi,
    I've developed a custom taskflow to be deployed in the webcenter spaces. The taskflow that I developed contains managed beans. I am using oracle provided build script with the sample application, to deploy custom taskflow. After the build, we don't see any .class files (managed bean files) in the generated war file. Once we deploy the taskflow into the space, it is failing may be because the managed bean class files are missing in the <taskflow>.war. Am i missing something? Should we specifically include the .class files in the build script?
    Below is the oracle provide build script..
    <?xml version="1.0" encoding="US-ASCII" ?>
    <!--Ant buildfile generated by Oracle JDeveloper-->
    <!--Generated Sep 29, 2009 11:47:41 PM-->
    <project name="WebCenterSpacesSharedLibExtension" default="all" basedir="."
    xmlns:wls="oracle.webcenter.tools.wls">
    <property file="../config.properties"/>
    <property file="build.properties"/>
    <import file="internal-targets.xml"/>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
    <pathelement location="${jdeveloper.install.home.directory}/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar"/>
    </classpath>
    </taskdef>
    <target name="clean-stage"
    description="Cleans the output directory and generates the war"
    depends="clean, stage"/>
    <target name="deploy-shared-lib"
    depends="init-wls"
    description="Deploy the extending WebCenter shared library">
    <echo> ---------------------------- </echo>
    <echo> ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded ${wls.webcenter.app.target} ${customer.library.name}</echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <!--TODO:ExpDeploy Uncomment line after this and comment the one after that to deploy exploded. -->
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded/${customer.library.name}.war ${wls.webcenter.app.target} ${customer.library.name}"/>
    <!--TODO:ExpDeploy Uncomment line below and comment line above to have non-exploded deploy -->
    <!--arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/${shared.library.name} ${wls.webcenter.app.target} ${customer.library.name}"/-->
    </exec>
    <echo> ---------------------------- </echo>
    <echo> Restarting the app </echo>
    <echo> ---------------------------- </echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/redepwc.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} "/>
    </exec>
    </target>
    </project>
    Thanks in advance
    Nitin

    Hi,
    I've developed a custom taskflow to be deployed in the webcenter spaces. The taskflow that I developed contains managed beans. I am using oracle provided build script with the sample application, to deploy custom taskflow. After the build, we don't see any .class files (managed bean files) in the generated war file. Once we deploy the taskflow into the space, it is failing may be because the managed bean class files are missing in the <taskflow>.war. Am i missing something? Should we specifically include the .class files in the build script?
    Below is the oracle provide build script..
    <?xml version="1.0" encoding="US-ASCII" ?>
    <!--Ant buildfile generated by Oracle JDeveloper-->
    <!--Generated Sep 29, 2009 11:47:41 PM-->
    <project name="WebCenterSpacesSharedLibExtension" default="all" basedir="."
    xmlns:wls="oracle.webcenter.tools.wls">
    <property file="../config.properties"/>
    <property file="build.properties"/>
    <import file="internal-targets.xml"/>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
    <pathelement location="${jdeveloper.install.home.directory}/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar"/>
    </classpath>
    </taskdef>
    <target name="clean-stage"
    description="Cleans the output directory and generates the war"
    depends="clean, stage"/>
    <target name="deploy-shared-lib"
    depends="init-wls"
    description="Deploy the extending WebCenter shared library">
    <echo> ---------------------------- </echo>
    <echo> ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded ${wls.webcenter.app.target} ${customer.library.name}</echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <!--TODO:ExpDeploy Uncomment line after this and comment the one after that to deploy exploded. -->
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded/${customer.library.name}.war ${wls.webcenter.app.target} ${customer.library.name}"/>
    <!--TODO:ExpDeploy Uncomment line below and comment line above to have non-exploded deploy -->
    <!--arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/${shared.library.name} ${wls.webcenter.app.target} ${customer.library.name}"/-->
    </exec>
    <echo> ---------------------------- </echo>
    <echo> Restarting the app </echo>
    <echo> ---------------------------- </echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/redepwc.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} "/>
    </exec>
    </target>
    </project>
    Thanks in advance
    Nitin

  • How to include a java-class in a JSP.

    I have the following code in a jsp:
    <jsp:include page = "http://test1.testing.com:81/TestClass" />
    I throws the following error:
    Servlet failed with Exception
    java.io.IOException: Nested 404 error
    If I copy paste the url (http://test1.testing.com:81/TestClass) directly on the browser address, it successfully runs the class.

    Copy the servlet class file in the servletclasses folder in the weblogic server then give the code like this
    <jsp:include page="servlet/servletclassfiles" flush="true" />
    this will include the class file to your jsp page
    what ever server better put the servlet class file in the servlet class invoking area

  • How to include implicitely referenced class in swf?

    I have a setup where livecycle returns an array filled with instances of class MyClass with, among others, property aName.  MyClass implements MyInterface which has an accessor name, in the implementation MyClass name handles aName.  A component listens to an ArrayCollection filled with this array and its labelField property is set to name.
    What happens next is a guess but seems plausible to me.  Due to the fact MyClass is not referenced in the application, I don't need it for the dataprovider, it isn't included in the swf file.  The result is an array not filled with MyClass instances but with Object instances with the aName property because livecycle seems to use a failover strategy where dynamic objects will be created if the class can't been found.  This results in an error for the component because the labelField doesn't exist here.
    My question is: is there a way to force Flex to include files?  I know I can handle this with changing the labelField but I want to stick to my design.

    I don't know it this will help you but in a flex lib nature project you can include the classes you need from the file .flexLibProperties. You can try to include into your .flexProperties file the next argument:
    <includeClasses>
    <classEntry path="com.validator.CustomValidator"/>
    </includeClasses>, but I didn't had the time to test so i can tell you for sure that it will work.

  • How to include a .class file in a jsp page

    hi everyone,
    i know the syntax as:
    <%@ include file = "filename.class" %>
    then at run time the server could not find the class file
    if i use,
    <%@ page import = "FileName.class" %>
    then also the same problem persists
    & if i use
    <jsp:include page = "Relative address"/>
    the problem still remains as it is...
    please help me out...i am working on developing an EJB application in which client interacts with server's Stateful session bean through a jsp page...it is necessary for me to include the home interface class file in my jsp page.
    P.S. do not suggest me to include the class file in a package & then use
    <%@ page import = "packageName.ClassFileName" %>
    i
    Edited by: Ankit_JIITU on 6 Jul, 2008 1:55 AM

    Ankit_JIITU wrote:
    i have already included the remote interface class file by <%@ page import = "University.RemoteInterfaceName" %>in my jsp page ...
    if i try to make a new package called test & then include my home interface in that package...i need to import University.*to generate the class file of my home interface ; but the class file generation is not taking place as i am getting the error..
    "package University does not exist".How can i overcome this problem. The package University, which you are trying to import, must be in the classpath. If you removed it then you will have to add it back.
    i have tried my best..but tell me if there's any possible way of including a class file in the jsp page without involving a package.No, there isn't.
    If not,then pls help me to generate the class file of my home interface within a package called test.Read the New To Java Tutorial and understand how packages work.
    >
    i am assuming that u have a deep knowledge of developing EJB applications.

  • How to include the class AI in visual c++?

    I'm doing an application, I declared the AI functions as subfunctions in another class, when I compile, the compliler says the AI undeclared. So I was thinking of anyway that can include the AI in the class? or the AI cannot be included into another class? thanks

    I'd suggest you take a look at the VC++ examples that use the CWAI. See this DevExchange post:
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000FE6F0000&UCATEGORY_0=_48_%24_7_&UCATEGORY_S=0
    Regards,
    Azucena

  • Flex SDK4 - import built in class error

    How are you?
    I am writing a very simple class, which I am trying to compile with ./mxmlc found in Flex SDK4. However I am getting the below errors, it seems like the built in classes cannot be found. I am not sure why the FLVPlayback or VideoPlayer or VideoElement components do not get included. I checked the SVN, and I cannot find any reference to these components.
    1) All I am trying to do is to get Video to display, using the Flex SDK4 compiler with AS3 files. Why the elements do not import? and What elements could I use for this to work?
    package {
         import flash.display.Sprite;
         import fl.video.FLVPlayback;
         public class Welcome extends Sprite {
              private var _video:FLVPlayback;
              private var _videoPath:String = "InsideJob.f4v";
              public function Welcome():void {
                   build();
         protected function build():void {
                   _video = new FLVPlayback();
                   _video.play(_videoPath);
                   var _place = new Position(200, 500);
                   _video.x = _place.xvalue();
                   _video.y = _place.yvalue();
                   stage.addChild(_video)
    ERRORS -----
    --FLVPlayback
    col: 22 Error: Type was not found or was not a compile-time constant: FLVPlayback.
    private var _video:FLVPlayback;
    col: 17 Error: Call to a possibly undefined method FLVPlayback.
    _video = new FLVPlayback();
    --Spark
    col: 25 Error: Definition spark.components:VideoElement could not be found.
    import spark.components.VideoElement;
    col: 22 Error: Type was not found or was not a compile-time constant: VideoElement.
    private var _video:VideoElement;

    How are you?
    I am writing a very simple class, which I am trying to compile with ./mxmlc found in Flex SDK4. However I am getting the below errors, it seems like the built in classes cannot be found. I am not sure why the FLVPlayback or VideoPlayer or VideoElement components do not get included. I checked the SVN, and I cannot find any reference to these components.
    1) All I am trying to do is to get Video to display, using the Flex SDK4 compiler with AS3 files. Why the elements do not import? and What elements could I use for this to work?
    package {
         import flash.display.Sprite;
         import fl.video.FLVPlayback;
         public class Welcome extends Sprite {
              private var _video:FLVPlayback;
              private var _videoPath:String = "InsideJob.f4v";
              public function Welcome():void {
                   build();
         protected function build():void {
                   _video = new FLVPlayback();
                   _video.play(_videoPath);
                   var _place = new Position(200, 500);
                   _video.x = _place.xvalue();
                   _video.y = _place.yvalue();
                   stage.addChild(_video)
    ERRORS -----
    --FLVPlayback
    col: 22 Error: Type was not found or was not a compile-time constant: FLVPlayback.
    private var _video:FLVPlayback;
    col: 17 Error: Call to a possibly undefined method FLVPlayback.
    _video = new FLVPlayback();
    --Spark
    col: 25 Error: Definition spark.components:VideoElement could not be found.
    import spark.components.VideoElement;
    col: 22 Error: Type was not found or was not a compile-time constant: VideoElement.
    private var _video:VideoElement;

  • How to include a jsp page in another jsp jsp page

    hi,
    i m trying to include a jsp page name "header.jsp" into one jsp page name"selectattribute.jsp" i m using these commands in "selectattribute.jsp"
    <%@include file "header.jsp"%> bcz both these jsp page are C:\program files\tomcat 4.0\webapps\examples\jsp\Poject\
    but the problem is that , i m invoking this jsp page "selectattribute.jsp" from a servlet reportcontroller.java using REQUEST DISPATCHER.
    the servlet is in
    C:\Program files\tomcat 4.0\webapps\examples\WEB-INF\classes\Project\
    i want to know how to include some other jsp page in a jsp page and how to invoke applet from jsp page when that particular jsp page is being invoked by servlet.
    plz help
    manish

    use this for including in your selectattribute.jsp
    <jsp:include page="header.jsp" flush="true"/>
    I never tried calling an applet. I think you can write the code for calling the applet in a javabean method and call the method in the jsp

  • How to use built in microphone on ipad3 I have Siri on but no icon shows on my keyboard just want to record voice

    How to use built in microphone on ipad3 just for audio no dictation

    If you just want to record a a voice memo, use the included Voice Memos app. That has nothing to do with Siri.

  • Include rt.jar class files in my own jar file to run 1.2+ applets on MS JVM

    My problem is this. I'm writing an applet (which includes 1.2 classes) for my organization (over 2000 NT workstations) in which no one has administrative privelages to install Sun's JRE 1.2 or greater. The target browser is IE 5. Our NT admins are having problems pushing the JRE out so my only two options are to rewrite everything as 1.1 or somehow include the missing class files from rt.jar.
    I really do not want to rewrite it all!
    I was able to extract the missing class files (i.e. /java/util/HashMap.class) but I cannot figure out how to get the IE JVM to use them. Things I have tried:
    1. jarred up all my class files along with the missing classes from rt.jar.
    $ jar cvf test.jar *.class java
    added manifest
    adding: ArrayObj.class(in = 731) (out= 448)(deflated 38%)
    adding: DivMonGrid.class(in = 1509) (out= 812)(deflated 46%)
    adding: GridLayout2.class(in = 2720) (out= 1514)(deflated 44%)
    adding: Item.class(in = 317) (out= 232)(deflated 26%)
    adding: Row.class(in = 588) (out= 365)(deflated 37%)
    adding: Screen.class(in = 672) (out= 416)(deflated 38%)
    adding: Site.class(in = 545) (out= 360)(deflated 33%)
    adding: divmonDash.class(in = 12506) (out= 6892)(deflated 44%)
    adding: java/(in = 0) (out= 0)(stored 0%)
    adding: java/util/(in = 0) (out= 0)(stored 0%)
    adding: java/util/HashMap.class(in = 6668) (out= 3461)(deflated 48%)
    adding: java/util/HashMap$1.class(in = 931) (out= 513)(deflated 44%)
    adding: java/util/HashMap$2.class(in = 800) (out= 454)(deflated 43%)
    adding: java/util/HashMap$3.class(in = 1608) (out= 904)(deflated 43%)
    adding: java/util/HashMap$EmptyHashIterator.class(in = 592) (out= 358)(deflated 39%)
    adding: java/util/HashMap$Entry.class(in = 1505) (out= 775)(deflated 48%)
    adding: java/util/HashMap$HashIterator.class(in = 1814) (out= 1096)(deflated 39%)
    $ jar -tf test.jar
    META-INF/
    META-INF/MANIFEST.MF
    ArrayObj.class
    DivMonGrid.class
    GridLayout2.class
    Item.class
    Row.class
    Screen.class
    Site.class
    divmonDash.class
    java/
    java/util/
    java/util/HashMap.class
    java/util/HashMap$1.class
    java/util/HashMap$2.class
    java/util/HashMap$3.class
    java/util/HashMap$EmptyHashIterator.class
    java/util/HashMap$Entry.class
    java/util/HashMap$HashIterator.class
    RESULT: IE JVM complains classnotfoundexception (its complaining about not finding HashMap.class)
    2. Tried to just place missing *.class files in same directory as my class files
    RESULT: Compiler error (complaining about file not be in correct path package) I understand this because when it was created the package statement has the class file in java/util/.
    If anyone has done this before or knows how to do it, please help me out.
    Thanks!

    When the collection classes first came out, I think they were available in a separate jar (although the package name may be slightly different). If it's just collection classes, that might be worthwhile looking at.
    The MS JVM may be spewing because the class format is too new; you may try with rt.jar classes from an older JVM (such as JDK 1.2), or try to recompile them from source using -target 1.1.

  • How to include .jar files in coldfusion code 

    To Integrate our cfm code with paypal jar files we do the
    following steps with our local coldfusion server ,and to run and
    integrate the paypal Java SDK jar files, I think we need to do the
    same process on the server, can you suggest any thing to do the
    following setting for my domain on the server, without setting the
    class path in coldfusion administrator.
    The ColdFusion application server must be configured to know
    the location of the PayPal JAR
    files, and your ColdFusion Markup (CFM) pages must be
    configured with the absolute path to
    the PayPal API certificate for the PayPal API user on whose
    behalf the calls are made.
    1. Install the PayPal Java SDK “Installing the
    SDK”.
    2. Copy a subset of the Java SDK JAR files to a location
    accessible by the ColdFusion
    application server. The JAR files are in SDK_root\lib and
    their exact names are as
    follows:
    – bcmail-jdk14-128.jar
    – bcprov-jdk14-128.jar
    – paypal_base.jar
    – paypal_stubs.jar
    sax2.jar
    – xerces.jar
    – xpp3-1.1.3.4d_b4_min.jar
    – xstream.jar-1.1.3.jar
    3. With the ColdFusion Application Server Administrator, add
    the absolute path of the
    location you determined in Step 2 to the Java and JVM
    CLASSPATH environment variable.
    4. Restart the ColdFusion Application Server.
    Suggest me how to include .jar files without setting
    classpath.

    > Suggest me how to include .jar files without setting
    classpath.
    Copy them to {CF_HOME}\lib, where {CF_HOME} is, for example,
    C:\CFusionMX7. Restart Coldfusion.

  • How to include custom application.xml in JDev9i project

    Can anybody explain to me how to include a custom application.xml file when deploying to an .ear file? I need to include application wide security roles, and I can't see where in Jev9i how to do this.
    After searching this forum, I see that jdev9i can't include the orion-application.xml, but I want to include just the standard J2EE application.xml. Is this possible?
    Thanks,
    matt

    The standard application.xml file unfortunately can't be customized in JDev 9.0.2. The reasons why this capability was left out of JDev 9.0.2 are same reasons why the other EAR-level XML files were excluded. The OTN thread
    Re: Regarding 11i and E-business suite
    has a summary of those reasons, which you've probably seen. We know this is an area in need of improvement and will be adding this functionality in the JDev 9.0.3 release. Until then, you'll have to go with a work-around like an Ant build file, batch file, Java application, or some other kind of script.
    Below is a sample Java application which can be used to insert <security-role> elements into an EAR file's application.xml. Modify the main() method to customize for your purposes, and put xmlparserv2.jar on the classpath (in a JDev project, add the "Oracle XML Parser v2" library):
    package mypackage4;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    public class PostProcessEAR
    public static void main( String[] args ) throws IOException
    final String earFile = "C:\\temp\\myapp.ear";
    final PostProcessEAR postProcess = new PostProcessEAR( earFile );
    postProcess.addSecurityRole( null, "first_role" );
    postProcess.addSecurityRole( "Description for the second role", "second_role" );
    postProcess.commit();
    System.out.println( "Done." );
    private final File _earFile;
    private final ArrayList _securityRoles = new ArrayList();
    public PostProcessEAR( String earFile )
    _earFile = new File( earFile );
    public void addSecurityRole( String description, String roleName )
    if ( roleName == null )
    throw new IllegalArgumentException();
    _securityRoles.add( description );
    _securityRoles.add( roleName );
    * Write out modified EAR file.
    public void commit() throws IOException
    if ( _securityRoles.size() == 0 )
    return;
    final ZipFile zipFile = new ZipFile( _earFile );
    final Enumeration entries = zipFile.entries();
    final File outFile = new File( _earFile.getAbsolutePath() + ".out" );
    final ZipOutputStream out = new ZipOutputStream( new BufferedOutputStream( new FileOutputStream( outFile ) ) );
    while ( entries.hasMoreElements() )
    final ZipEntry entry = (ZipEntry) entries.nextElement();
    final InputStream in = zipFile.getInputStream( entry );
    if ( "META-INF/application.xml".equals( entry.getName() ) )
    final XMLDocument modifiedApplicationXml = insertSecurityRoles( in );
    final ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    modifiedApplicationXml.print( byteOutput );
    final int numBytes = byteOutput.size();
    entry.setSize( numBytes );
    if ( entry.getMethod() == ZipEntry.STORED )
    entry.setCompressedSize( numBytes );
    final CRC32 crc32 = new CRC32();
    crc32.update( byteOutput.toByteArray() );
    entry.setCrc( crc32.getValue() );
    out.putNextEntry( entry );
    byteOutput.writeTo( out );
    else
    // Copy all other zip entries as they are.
    out.putNextEntry( entry );
    copy( in, out );
    in.close();
    out.close();
    private XMLDocument insertSecurityRoles( InputStream in ) throws IOException
    final DOMParser domParser = new DOMParser();
    domParser.setAttribute( DOMParser.STANDALONE, Boolean.TRUE );
    try
    domParser.parse( in );
    final XMLDocument doc = domParser.getDocument();
    final Element docElem = doc.getDocumentElement();
    final Iterator iter = _securityRoles.iterator();
    while ( iter.hasNext() )
    final String desc = (String) iter.next(); // might be null
    final String roleName = iter.next().toString(); // must not be null
    final Element securityRoleElem = doc.createElement( "security-role" );
    if ( desc != null )
    securityRoleElem.appendChild( createPcdata( doc, "description", desc ) );
    securityRoleElem.appendChild( createPcdata( doc, "role-name", roleName ) );
    docElem.appendChild( securityRoleElem );
    return doc;
    catch ( SAXException e )
    e.printStackTrace();
    return null;
    private Element createPcdata( XMLDocument doc, String elemName, String pcdata )
    final Element elem = doc.createElement( elemName );
    elem.appendChild( doc.createTextNode( pcdata ) );
    return elem;
    private final byte[] buffer = new byte[4096];
    private void copy( InputStream in, OutputStream out ) throws IOException
    while ( true )
    final int bytesRead = in.read( buffer );
    if ( bytesRead < 0 )
    break;
    out.write( buffer, 0, bytesRead );

  • How do you know what classes to use ?

    Hello,
    This may sound daft - but how do you know what classes to use to do a particular task ? For example to do password-related stuff - how would I know which classes are all relevant to that ? Am I supposed to buy a book on the classes as the API documentation doesn't really tell you WHEN to use which classes.

    If you're using JSP, then your password field is likely going to be implemented in HTML. So that's nothing to do with Java. (And you can't use a JPassword field in a JSP page.) But when that field comes back to your server, you may be using Java to authenticate it. Even there, the question is not yet what Java method you are going to use, but what methodology. You could have a database to authenticate against, or an LDAP directory. Or you could have the web server use its built-in authentication, which means you don't have to do any Java coding at all. And there are other ways.
    So the question before yours is, how do you know what methodology to use? Again, that comes down to experience.

  • How to include md5 package in application

    Hi All,
    First of all sorry I posted in another users thread. In the thread http://forums.sun.com/thread.jspa?threadID=5426671 the person used org.bouncycastle.crypto.digests.MD5Digest for doing md5.
    I need some help here on how you include the org.bouncycastle.crypto.digests.MD5Digest library in my java code as I want to use the md5.
    I am also working on something similar like that but without the web application part and a detail which consists on OTP part using md5.
    As the md5() doesn't work in j2me so was also searching for something which will work on MIDP.
    package com.abc; //package define
    public class messDig5 //class define
        private String generateHash(String OTP, int loopNum) {
            byte[] secretBytes = OTP.getBytes();
            for (int x = 0; x < loopNum; x++) {
                byte[] tempStore = new byte[16];
                tempStore = hash(secretBytes);
                secretBytes = tempStore;
         //   return convertToHex(secretBytes);
            return byteArrayToHexString(secretBytes);
        public byte[] hash(byte[] secretBytes) {
           org.bouncycastle.crypto.digests.MD5Digest digest = new org.bouncycastle.crypto.digests.MD5Digest();
            digest.reset();
            // Update MD5 digest with user secret in byte format
            digest.update(secretBytes, 0, secretBytes.length);
            // get length of digest to initialise new md5 byte array
            int length = digest.getDigestSize();
            // create md5 byte array using length
            byte[] md5 = new byte[length];
            // calculate MD5 hash, using md5 byte array, 0 for buffer offset
            digest.doFinal(md5, 0);
            return md5;
    //    private static String convertToHex(byte[] data) {
    //        StringBuffer buf = new StringBuffer();
    //        String Hex;
    //        String formattedHex;
    //        for (int i = 0; i < data.length; i++) {
    //            int halfbyte = (data[i] >>> 4) & 0x0F;
    //            int two_halfs = 0;
    //            do {
    //                if ((0 <= halfbyte) && (halfbyte <= 9)) {
    //                    buf.append((char) ('0' + halfbyte));
    //                } else {
    //                    buf.append((char) ('a' + (halfbyte - 10)));
    //                halfbyte = data[i] & 0x0F;
    //            } while (two_halfs++ < 1);
    //        Hex = buf.toString();
    //        formattedHex = "\n" + Hex.substring(0, 4) + " " + Hex.substring(4, 8) + " " + Hex.substring(8, 12) + " " + Hex.substring(12, 16) + " " + Hex.substring(16, 20) + " " + Hex.substring(20, 24) + " " + Hex.substring(24, 28) + " " + Hex.substring(28, 32);
    //        return formattedHex;
        static String byteArrayToHexString(byte byteValues[]) {
            byte singleChar = 0;
            if (byteValues == null || byteValues.length <= 0) {
                return null;
            String entries[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                "a", "b", "c", "d", "e", "f"};
            StringBuffer out = new StringBuffer(byteValues.length * 2);
            for (int i = 0; i < byteValues.length; i++) {
                singleChar = (byte) (byteValues[i] & 0xF0);
                singleChar = (byte) (singleChar >>> 4);
                // shift the bits down
                singleChar = (byte) (singleChar & 0x0F);
                out.append(entries[(int) singleChar]);
                singleChar = (byte) (byteValues[i] & 0x0F);
                out.append(entries[(int) singleChar]);
            String rslt = new String(out);
            return rslt;

    Camellia,
    I take you already added bouncycatsle to your project as a compile dependency, since it compiles (unless it does not).
    All you have to do for your code to work on the phone, you need to build your JAR file (that you use to distribute your MIDlet) with bouncycastle packaged in. This will all depend on the method you use to build your JAD and JAR files.
    I use antenna tool, which provides me with ant tasks to compile, build jar, package external libraries etc. Your scenario can be different, but all you have to do is to search manuals and/or google for methods on how to package external libraries with your build.
    Daniel

Maybe you are looking for