Purpose of .jar

Hello,All !
I am a begaining of java learner.I want to know about the purpose of .jar file.
And which way I should use for changing .jar file in eclipse platform.If you know,please tell me.
Thanks.

JAR "java archive" file lets you compress your various files, of a project.
JAR is a special format that can be used by Java technologies to transfer, read numerous files of a given application / project at a single go.
Ex: An mobile device can download a single jar file that can represent a whole application. Because jar compresses .class files, image files, etc. - the download is much faster. The mobile device program then unzips and executes the .class files - letting you have faster access to your downloaded application.
Google "define:jar" to get more information on JAR

Similar Messages

  • Purpose of jar file

    what is a jar file.
    what is it s purpose and where isit used
    thank you

    Bookmark this page, then whenever you get an urge to ask a basic Java question, check there first.
    http://java.sun.com/j2se/1.4.1/docs/index.html
    Do a search on this page for "jar".

  • Ear, war and jar question.

    Hi Communtiy,
    Can I split an ear file to a war file on one computer and to a jar file on an other computer, or doesnt it makes sense.
    Thanks
    Oliver.

    we can....I am not sure in which circumstances you need this.
    There are no structural differences between the files; they are all archived using zip/jar compression. However, they are intended for different purposes.
    Jar files (files with a .jar extension) are intended to hold generic libraries of Java classes, resources, auxiliary files, etc.
    War files (files with a .war extension) are intended to contain complete Web applications. In this context, a Web application is defined as a single group of files, classes, resources, .jar files that can be packaged and accessed as one servlet context.

  • What is the difference between admin.jar and admin_client.jar

    Oc4j provide two jar for admin purpose: admin.jar and admin_client.jar. what are the differnce between them?

    I'm sure I've provided an answer for this before -- try searching this forum and see if its there.
    In short: admin.jar is old and uses a bunch of internal APIs.
    admin_client.jar is a new implementation in 10.1.3.x and it uses JMX/JSR77/JSR88 APIs as its basis. It supports config/deployment operations against ALL the OC4J variants -- standalone, OracleAS single instance or OracleAS groups. We've tried to ensure that admin_client.jar has all the necessary coverage from admin.jar -- the syntax is very similar and all the relevant commands are carried forward.
    If you are making a choice, choose admin_client.jar.
    -steve-

  • JSP, HTML, CLASS, JAVASCRIPTS TO EXE OR PACKAGES

    Sir / Madam,
    I am a student, I am learning by myself. Plz help me.
    Can we create a package or exe which contains all JSP , HTML and their corresponding Images and Javascripts. Then extract in the server.
    ie: Server should not contain source code. It should in the form of EXE or other forms.
    Expecting Early replay.
    Thank You,
    Rengaraj

    hI renga_murali, well here is my openion about your thread. Hope you will get what you are looking for exactly.
    JAR files = collection of class files
    WAR files = collection of class, JSP, XML files
    EAR files = collection of JAR, WAR, and EJBs
    There are no structural differences between the files; they are all archived using zip/jar compression. However, they are intended for different purposes.
    Jar files (files with a .jar extension) are intended to hold generic libraries of Java classes, resources, auxiliary files, etc.
    War files (files with a .war extension) are intended to contain complete Web applications. In this context, a Web application is defined as a single group of files, classes, resources, .jar files that can be packaged and accessed as one servlet context.
    Ear files (files with a .ear extension) are intended to contain complete enterprise applications. In this context, an enterprise application is defined as a collection of .jar files, resources, classes, and multiple Web applications.
    Each type of file (.jar, .war, .ear) is processed uniquely by application servers, servlet containers, EJB containers, etc.
    ALSO REFER :
    Creating a JAR File : http://java.sun.com/docs/books/tutorial/jar/basics/build.html
    Creating a WAR File :
    http://access1.sun.com/techarticles/simple.WAR.html
    Creating a EAR File :
    http://access1.sun.com/techarticles/DissectingEARs/DissectingEARs.html
    Threads :
    http://forum.java.sun.com/thread.jspa?threadID=483657&messageID=2258904
    http://forum.java.sun.com/thread.jspa?threadID=455102&messageID=2075155
    Explaination :
    http://www.cezwright.com/tools/java/jar_war_ear.htm

  • What is the purpose of alt-rt.jar in jdk1.6.0_20/jre/lib -- 64bit

    what is the purpose of alt-rt.jar in jdk1.6.0_20/jre/lib -- 64bit
    thanks

    Could this be because of one of these bugs:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6953058
    or
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6959816
    Actually the flags from the later bug are not set in our JVM but the crash happened between half an hour or several hours (I expect it was depending on the system load).
    Thanks,
    Stefan

  • [svn:bz-trunk] 17982: Bug: BLZ-564 - Some classes in flex-messaging-core. jar define main methods for debugging purposes.

    Revision: 17982
    Revision: 17982
    Author:   [email protected]
    Date:     2010-10-01 00:39:15 -0700 (Fri, 01 Oct 2010)
    Log Message:
    Bug: BLZ-564 - Some classes in flex-messaging-core.jar define main methods for debugging purposes. This creates an unintended entry point and the main methods should be removed.
    QA: No - just removed main methods
    Doc: No
    Checkintests: No - just removed main methods
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-564
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/services/messaging/selector/NumericValue.ja va
        blazeds/trunk/modules/core/src/flex/messaging/util/Base64.java
        blazeds/trunk/modules/core/src/flex/messaging/util/Hex.java
    Added Paths:
        blazeds/trunk/modules/core/test/src/flex/messaging/util/Basae64Test.java

  • Adding JAR file to project

    Hi All
    How can i add jar to my project environment.
    Actually what i did was.
    Created one folder called "JavaWork" like d:\JavaWork
    and put the jar file into this folder and wrote a test class which is importing some classes from the jar file.
    how to use jar ? Please someone help me.
    Thanks in advance
    Shan

    `man jar`
    jar(1) jar(1)
    NAME
    jar - Java archive tool
    SYNOPSIS
    jar [ -C ] [ c ] [ f ] [ i ] [ M ] [ m ] [ O ] [ t ] [ u ]
    [ v ]
    [ x file ] [ manifest-file ] destination input-file
    [ input-files ]
    DESCRIPTION
    The jar tool is a Java application that combines multiple
    files into a single JAR archive file. It is also a gen-
    eral-purpose archiving and compression tool, based on ZIP
    and the ZLIB compression format. However, jar was
    designed mainly to facilitate the packaging of Java
    applets or applications into a single archive. When the
    components of an applet or application (.class files,
    images and sounds) are combined into a single archive,
    they can be downloaded by a Java agent (like a browser) in
    a single HTTP transaction, rather than require a new con-
    nection for each piece. This dramatically improves down-
    load time. The jar tool also compresses files, which fur-
    ther improves download time. In addition, it allows indi-
    vidual entries in a file to be signed by the applet author
    so that their origins can be authenticated. The syntax
    for the jar tool is almost identical to the syntax for the
    tar(1) command. A jar archive can be used as a class path
    entry, whether or not it is compressed.
    The three types of input files for the jar tool are:
    o Manifest file (optional)
    o Destination jar file
    o Files to be archived
    Typical usage is:
    example% jar cf myjarfile *.class
    In this example, all the class files in the current direc-
    tory are placed in the file named myjarfile. A manifest
    file is automatically generated by the jar tool and is
    always the first entry in the jar file. By default, it is
    named META-INF/MANIFEST.MF. The manifest file is the
    place where any meta-information about the archive is
    stored. Refer to the Manifest Format in the SEE ALSO sec-
    tion for details about how meta-information is stored in
    the manifest file.
    To use a pre-existing manifest file to create a new jar
    archive, specify the old manifest file with the m option:
    example% jar cmf myManifestFile myJarFile *.class
    When you specify cfm instead of cmf (that is, you invert
    the order of the m and f options), you need to specify the
    name of the jar archive first, followed by the name of the
    manifest file:
    example% jar cfm myJarFile myManifestFile *.class
    The manifest uses RFC822 ASCII format, so it is easy to
    view and process manifest-file contents.
    OPTIONS
    The following options are supported:
    -C Changes directories during execution of the jar com-
    mand. For example:
    example% jar uf foo.jar -C classes *
    c Creates a new or empty archive on the standard out-
    put.
    f The second argument specifies a jar file to process.
    In the case of creation, this refers to the name of
    the jar file to be created (instead of on stdout).
    For table or xtract, the second argument identifies
    the jar file to be listed or extracted.
    i Generates index information for the specified jar
    file and its dependent jar files. For example,
    example% jar i foo.jar
    would generate an INDEX.LIST file in foo.jar which con-
    tains location information for each package in foo.jar and
    all the jar files specified in foo.jar's Class-Path
    attribute.
    M Does not create a manifest file for the entries.
    m Includes manifest information from specified pre-
    existing manifest file. Example use:
    example% jar cmf myManifestFile myJarFile *.class
    You can add special-purpose name-value attribute
    headers to the manifest file that are not contained
    in the default manifest. Examples of such headers
    are those for vendor information, version informa-
    tion, package sealing, and headers to make JAR-bun-
    dled applications executable. See the JAR Files
    trail in the Java Tutorial and the JRE Notes for
    Developers web page for examples of using the m
    option.
    O Stores only, without using ZIP compression.
    t Lists the table of contents from standard output.
    u Updates an existing JAR file by adding files or
    changing the manifest. For example:
    example% jar uf foo.jar foo.class
    adds the file foo.class to the existing JAR file
    foo.jar, and
    example% jar umf foo.jar
    updates foo.jar's manifest with the information in
    manifest.
    v Generates verbose output on stderr.
    x file
    Extracts all files, or just the named files, from
    standard input. If file is omitted, then all files
    are extracted; otherwise, only the specified file or
    files are extracted.
    If any of the files is a directory, then that direc-
    tory is processed recursively.
    EXAMPLES
    To add all of the files in a particular directory to an
    archive:
    example% ls
    0.au 3.au 6.au 9.au at_work.gif
    1.au 4.au 7.au Animator.class monkey.jpg
    e.au 5.au 8.au Wave.class spacemusic.au
    example% jar cvf bundle.jar *
    adding: 0.au
    adding: 1.au
    adding: 2.au
    adding: 3.au
    adding: 4.au
    adding: 5.au
    adding: 6.au
    adding: 7.au
    adding: 8.au
    adding: 9.au
    adding: Animator.class
    adding: Wave.class
    adding: at_work.gif
    adding: monkey.jpg
    adding: spacemusic.au
    example%
    If you already have subdirectories for images, audio
    files, and classes that already exist in an HTML direc-
    tory, use jar to archive each directory to a single jar
    file:
    example% ls
    audio classes images
    example% jar cvf bundle.jar audio classes images
    adding: audio/1.au
    adding: audio/2.au
    adding: audio/3.au
    adding: audio/spacemusic.au
    adding: classes/Animator.class
    adding: classes/Wave.class
    adding: images/monkey.jpg
    adding: images/at_work.gif
    example% ls -l
    total 142
    drwxr-xr-x 2 brown green 512 Aug 1 22:33 audio
    -rw-r--r-- 1 brown green 68677 Aug 1 22:36 bundle.jar
    drwxr-xr-x 2 brown green 512 Aug 1 22:26 classes
    drwxr-xr-x 2 brown green 512 Aug 1 22:25 images
    example%
    To see the entry names in the jar file using the jar tool
    and the t option:
    example% ls
    audio bundle.jar classes images
    example% jar tf bundle.jar
    META-INF/MANIFEST.MF
    audio/1.au
    audio/2.au
    audio/3.au
    audio/spacemusic.au
    classes/Animator.class
    classes/Wave.class
    images/monkey.jpg
    images/at_work.gif
    example%
    To display more information about the files in the
    archive, such as their size and last modified date, use
    the v option:
    example% jar tvf bundle.jar
    145 Thu Aug 01 22:27:00 PDT 1996 META-INF/MANIFEST.MF
    946 Thu Aug 01 22:24:22 PDT 1996 audio/1.au
    1039 Thu Aug 01 22:24:22 PDT 1996 audio/2.au
    993 Thu Aug 01 22:24:22 PDT 1996 audio/3.au
    48072 Thu Aug 01 22:24:23 PDT 1996 audio/spacemusic.au
    16711 Thu Aug 01 22:25:50 PDT 1996 classes/Animator.class
    3368 Thu Aug 01 22:26:02 PDT 1996 classes/Wave.class
    12809 Thu Aug 01 22:24:48 PDT 1996 images/monkey.jpg
    527 Thu Aug 01 22:25:20 PDT 1996 images/at_work.gif
    example%
    If you bundled a stock trade application (applet) into the
    following jar files,
    main.jar buy.jar sell.jar other.jar
    and you specified the Class-Path attribute in main.jar's
    manifest as
    Class-Path: buy.jar sell.jar other.jar
    then you can use the i option to speed up your applica-
    tion's class loading time:
    example$ jar i main.jar
    An INDEX.LIST file is inserted in the META-INF directory
    which will enable the application class loader to download
    the right jar files when it is searching for classes or
    resources.
    SEE ALSO
    keytool(1)
    JAR Files @
    http://java.sun.com/docs/books/tutorial/jar/
    JRE Notes @
    http://java.sun.com/j2se/1.3/runtime.html#exam-
    ple
    JAR Guide @
    http://java.sun.com/j2se/1.3/docs/guide/jar/index.html
    For information on related topics, use the search link @
    http://java.sun.com/
    13 June 2000 jar(1)

  • Error in the standard htmlb.jar from EP6 SP9 (HTMLx)

    I've successfully migrated my custom developed applications from EP5 SP5 to EP6 SP9. I've used the well known 3rd party
    HTMLxframework for the DatePicker and Locale corrections only (I am a brazilian developer). 
    In the org.sapportals.htmlb.rendering there is a class named RenderUtil.
    This class has two places with this specific code:
    ResourceBundle r = ResourceBundle.getBundle("java.text.resources.LocaleElements", locale);
    Which is very wrong as the "java.text.resources.LocaleElements" is available only until j2sdk 1.3. In the EP5 that runs under 1.3 there's no problem but EP6 uses j2sdk 1.4 and this packages has been relocated from the standard package to a "ext" (extension) package and been renamed as "sun.text.resources.LocaleElements".
    So, as HTMLx uses this RenderUtil class, I had to decompile the original from the htmlb.jar using JAD and corrected the above line with the following new line or code:
    ResourceBundle r = ResourceBundle.getBundle("sun.text.resources.LocaleElements", locale);
    More than that, I had to change several places of the HTMLx's HxInputFieldRenderer to reflect the class name changes made to the CSSs of the EP6. In the new version SAP does not open a pop-up window for the DatePicker. Instead they chose to rewrite it as a dynamic layer. So the HTMLx code has to change to reflect that.
    Here follows the workaround version of HxInputFieldRenderer.java (notice that some strings are not internationalized, I just copied and pasted the parts I needed, so it's not a definitive version, but will help you get a clue of what to do):
    * HxInputFieldRenderer.java
    * Copyright (C) 2003  Alan Hobbs
    * This library is free software; you can redistribute it and/or
    * modify it under the terms of the GNU Lesser General Public
    * License as published by the Free Software Foundation; either
    * version 2.1 of the License, or (at your option) any later version.
    * This library is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    * Lesser General Public License for more details.
    * You should have received a copy of the GNU Lesser General Public
    * License along with this library; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    package org.open.sapportals.htmlx.rendering;
    import javax.servlet.jsp.PageContext;
    import org.open.sapportals.htmlx.HxField;
    import org.open.sapportals.htmlx.HxInputField;
    import org.open.sapportals.htmlx.HxLocaleUtil;
    import com.sapportals.htmlb.Component;
    import com.sapportals.htmlb.Form;
    import com.sapportals.htmlb.InputField;
    import com.sapportals.htmlb.enum.DataType;
    import com.sapportals.htmlb.enum.InputFieldDesign;
    import com.sapportals.htmlb.enum.ResourceType;
    import com.sapportals.htmlb.rendering.DefaultInputFieldRenderer;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.type.AbstractDataType;
    import com.sapportals.htmlb.type.DataDate;
    import com.sapportals.htmlb.type.DataString;
    import com.sapportals.htmlb.type.Date;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    import com.sapportals.portal.prt.logger.ILogger;
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    import com.sapportals.portal.prt.service.urlgenerator.IUrlGeneratorService;
    import com.sapportals.portal.prt.service.urlgenerator.specialized.IPortalUrlGenerator;
    import com.sapportals.portal.prt.service.urlgenerator.specialized.ISpecializedUrlGenerator;
    * @author Alan.Hobbs
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    * Render the HxInputField.
    * Version   Date         Author     Description
    * 0.1.0     1-Aug-2003   AHobbs     Origional
    * 0.1.0     4-Aug-2003   AHobbs     Added resource bundle
    * 0.1.1     6-Aug-2003   AHobbs     Write hidden fields to store the locale
    * 0.1.1     8-Aug-2003   AHobbs     Don't show the date picker button if the field is disabled
    * 0.1.2    10-Aug-2003   AHobbs     Only generate the month and day name javascript once per form
    * 1.1.0     1-Apr-2004   AHobbs     Added render methods to allow a HTMLB InputField
    *                                   to be used instead of a HxInputField
    * 1.1.0     6-Apr-2004   AHobbs     Changed the names for the hidden fields to "_HTMLX_xxxxx"
    * 1.1.0    20-Apr-2004   AHobbs     Allow debug code to be written to the console with System.out.println()
    * 1.3.0      4-May-2004  AHobbs     Added PopUp rendering
    public class HxInputFieldRenderer extends DefaultInputFieldRenderer {
        protected ILogger m_logger = PortalRuntime.getLogger("htmlx");
        private static boolean writingDebugToConsole;
        public HxInputFieldRenderer() {
            super();
        public void render(Component component, IPageContext pc)
            m_logger.info("Entry: HxInputFieldRenderer.render()");
            if (!(component instanceof HxInputField)) {
                m_logger.warning(
                    "HxInputFieldRenderer.render() component is not instanceof HxInputField " +
                    "(component.getClass().getName()='" + component.getClass().getName() + "')");
                return;       
            HxInputField inf = (HxInputField)component;
            DataType type = inf.getType();
            if (writingDebugToConsole) {
                System.out.println("Start    rendering HxInputField (id='" + inf.getId() + "') ...");
            m_logger.info("  id='" + inf.getId() + "'");
            m_logger.info(inf.toString());
    /*  Only include for PDK version 5.0.5.0 and above - may not be required ???
    //        m_logger.info("  VersionInfo.getVersion()='" + VersionInfo.getVersion() + "'");
    //      if (VersionInfo.?????) {
    //            if (pc.isUsingSession() && !inf.isVisible() && inf.getParkInSession()) {
    //                String uniqueName = pc.getParamIdForComponent(inf);
    //                Object value = inf.getValue();
    //                String valueString = null;
    //                if (value != null) {
    //                    if (value instanceof AbstractDataType) {
    //                        AbstractDataType dataValue = (AbstractDataType)value;
    //                        if (dataValue != null)
    //                            if (dataValue.isValid())
    //                                valueString = dataValue.toString(pc);
    //                            else
    //                            if (dataValue instanceof DataString)
    //                                valueString = dataValue.toString(pc);
    //                            else
    //                                valueString = dataValue.getValueAsString();
    //                    else {
    //                        valueString = value.toString();
    //                else {
    //                    valueString = "";
    //                pc.getParamList().put(uniqueName, valueString);
    //                return;
            boolean showDateHelp = false;
            if (DataType.DATE.equals(type)
            && inf.isShowHelp()
            && !inf.isDisabled()) {
                showDateHelp = true;
            boolean showPatternHint = false;
            if (inf.isShowPatternHint()
            && (DataType.DATE.equals(type)
            ||  DataType.TIME.equals(type))
            ||  ((inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0))) {
                showPatternHint = true;
            boolean showStatusMsg = false;
            if (inf.isShowStatusMsg() && (inf.getStatusMsg() != null) && (inf.getStatusMsg().length() > 0)) {
                showStatusMsg = true;
            if (showDateHelp || showPatternHint || showStatusMsg) {
                pc.write("<table cellspacing="0" cellpadding="0" border="0" id="");
                pc.write(""><tr><td>");
              String uniqueName = pc.getParamIdForComponent(inf);
            if (inf.isVisible()) {
                 pc.write("<span id="");
                   pc.write(uniqueName);
                 pc.write("-r" class="urEdfHelpWhl">");
                if (inf.isPassword())
                    pc.write("<input type="password" class="sapEdf");
                else
                    pc.write("<input type="text" class="sapEdf");
                if (inf.isInvalid())
                    pc.write("i");
                if (inf.isRequired())
                    pc.write("Req");
                else
                    pc.write("Txt");
                if (inf.isDisabled())
                    pc.write("Dsbl");
                else
                    pc.write("Enbl");
                if (inf.getDesign() == InputFieldDesign.SMALL)
                    pc.write("Sml");
                pc.write("" autocomplete="off");
                int mySize = inf.getSize();
                if (mySize > 0) {
                    pc.write("" size="");
                    pc.write(mySize);
                int maxlength = inf.getMaxlength();
                if (maxlength > 0) {
                    pc.write("" maxlength ="");
                    pc.write(maxlength);
                java.lang.String value = inf.getWidth();
                if (value != null && !"".equals(value)) {
                    pc.write("" style="width:");
                    pc.write(value);
                    pc.write(";");
                java.lang.String tooltip = inf.getTooltip();
                if (tooltip != null) {
                    pc.write("" title="");
                    pc.writeEncoded(tooltip);
                   pc.write(" onchange="return htmlbDoEvent(this,'TV','onchange','0','");
                   pc.write(uniqueName);
                   pc.write("',1,1,'',0);" "); 
                   pc.write(" onblur="return htmlbDoEvent(this,'TV','onblur','0','");
                   pc.write(uniqueName);
                   pc.write("',1,1,'',0);" ");
                if(inf.isDisabled())
                    pc.write("" readonly="");
            else {
                pc.write("<input type="hidden");
            pc.write("" name="");
            pc.write(uniqueName);
            if (inf.isLabeled()) {
                pc.write("" id="");
                pc.write(uniqueName);
            Object value = inf.getValue();
            pc.write("" value="");
            if (value != null) {
                String valueString = null;
                if (value instanceof AbstractDataType) {
                    m_logger.info("-- Abstract Data Type");
                    AbstractDataType dataValue = (AbstractDataType)value;
                    if (dataValue != null) {
                        m_logger.info("-- dataValue != null");
                        if (dataValue.isValid()) {
                            m_logger.info("-- dataValue.isValid()");
                            if (dataValue instanceof DataDate) {
                                m_logger.info("-- dataValue instanceof DataDate");
                                Date date = ((DataDate)dataValue).getValue();
                                valueString = HxLocaleUtil.formatDate(date, pc.getLocale());
                            else {                       
                                m_logger.info("-- NOT dataValue instanceof DataDate");
                                valueString = dataValue.toString(pc);
                        else if (dataValue instanceof DataString) {
                            m_logger.info("-- dataValue instanceof DataString");
                            valueString = dataValue.toString(pc);
                        else {
                            m_logger.info("-- dataValue.getValueAsString()");
                            valueString = dataValue.getValueAsString();
                else {
                    // Not Abstract Data Type
                    m_logger.info("-- Not Abstract Data Type");
                    valueString = value.toString();
                pc.writeEncoded(valueString);
            pc.write(""/>");
            if (showDateHelp) {
                String dateFormat  = HxLocaleUtil.getSapDatePatternNumber(pc.getLocale());       
                   pc.write("</td><td align='left'><button id='");
                   pc.write(uniqueName);
                   pc.write("-btn' type="button" tabindex="-1" ti="-1" class="urEdfHlpDate" onclick="htmlb_showDateHelp(event,'");
                   pc.write(uniqueName);
                   pc.write("','");
                   pc.write(dateFormat);
                   pc.write("','1')"></button>");
                   pc.write("<script>htmlb_addTexts('pt_BR',{SAPUR_OCTOBER:"Outubro",SAPUR_MSG_LOADING:"Processo de carga em andamento"," +
                        "SAPUR_SUNDAY_ABBREV:"Do",SAPUR_F4FIELD_TUTOR:"Pressionar F4 para exibir as entradas possíveis"," +
                        "SAPUR_INVALID:"Não válido",SAPUR_FEBRUARY:"Fevereiro",SAPUR_F4FIELD:"F4- campo de entrada"," +
                        "SAPUR_FRIDAY_ABBREV:"6ª",SAPUR_WEDNESDAY_ABBREV:"4ª",SAPUR_MAY:"Maio",SAPUR_MSG_WARNING:"Advertência"," +
                        "SAPUR_DECEMBER:"Dezembro",SAPUR_SEPARATOR:"-",SAPUR_MSG_SUCCESS:"Com êxito",SAPUR_SATURDAY_ABBREV:"Sa"," +
                        "SAPUR_THURSDAY_ABBREV:"5ª",SAPUR_MSG:"{0} {1} {2}",SAPUR_BUTTON_WHL:"{0} - {1} - {2} - {3}",SAPUR_JULY:"Julho"," +
                        "SAPUR_APRIL:"Abril",SAPUR_FIELD_TIME:"Hora",SAPUR_MSG_ERROR:"Erro",SAPUR_REQUIRED:"Necessário"," +
                        "SAPUR_BUTTON_WHL3:"{0} - {1} - {2}",SAPUR_SEPTEMBER:"Setembro",SAPUR_NOVEMBER:"Novembro",SAPUR_AUGUST:"Agosto"," +
                        "SAPUR_JANUARY:"Janeiro",SAPUR_BUTTON:"Botão",SAPUR_FIELD_PW:"Senha",SAPUR_FIELD:"Texto editável"," +
                        "SAPUR_DISABLED:"Não disponível",SAPUR_FIELD_DATE:"Data",SAPUR_MARCH:"Março",SAPUR_FIELD_NUMBER:"N°"," +
                        "SAPUR_MSG_STOP:"Stop",SAPUR_BUTTON_WHL4:"{0} - {1} - {2} - {3}"," +
                        "SAPUR_BUTTON_ENABLED:"Para ativar, utilizar a barra de espaço",SAPUR_TUESDAY_ABBREV:"3ª",SAPUR_READOLNY:""," +
                        "SAPUR_MSG_JUMPKEY:"Pressionar a barra de espaço para navegar para o campo correspondente",SAPUR_JUNE:"Junho"," +
                        "SAPUR_MONDAY_ABBREV:"2ª"});</script>");
            if (showPatternHint) {
                String pattern        = "";       
                String patternTooltip = "";
                if (DataType.DATE.equals(type)) {
                    pattern        = HxLocaleUtil.getDatePatternInLocaleLanguage(pc.getLocale());       
                    patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.DatePatternTooltip", pattern);
                else if (DataType.TIME.equals(type)) {
                    pattern        = HxLocaleUtil.getTimePatternInLocaleLanguage(pc.getLocale());       
                    patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.TimePatternTooltip", pattern);
                    pattern = " " + pattern;
                else if ((inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0)) {
                    pattern = " " + inf.getPatternHint();
                    patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.PatternTooltip", pattern);
                pc.write("</td><td align='left'>");
                pc.write("<span class='sapTxtLeg' title='" + patternTooltip + "'><nobr>");
                pc.write("<font color='666666' face='Microsoft Sans Serif' style='vertical-align:super' size='1'><b>" + pattern + "</b></font>");
                pc.write("</nobr></span>");
            if (showStatusMsg) {
                if (inf.getStatusMsgPosition().equalsIgnoreCase("RIGHT")) {
                    pc.write("</td><td align='left'>");
                    pc.write("<font color='990000' face='Microsoft Sans Serif' size='1'>");
                else if (inf.getStatusMsgPosition().equalsIgnoreCase("BELOW")) {
                    pc.write("</td></tr><tr>");
                    if (showDateHelp && showPatternHint) {
                        pc.write("<td align='left' colspan='3'>");
                    else if (showDateHelp ^ showPatternHint) {      // '^' is Exclusive OR (XOR)
                        pc.write("<td align='left' colspan='2'>");
                    else {
                        pc.write("<td align='left'>");
                    pc.write("<font color='990000' face='Microsoft Sans Serif' style='verticle-align:super' size='1'>");
                pc.write("<nobr>" + inf.getStatusMsg() + "</nobr>");
                pc.write("</font>");
            if (showDateHelp || showPatternHint || showStatusMsg) {
                pc.write("</td></tr></table>");
            // Generate code to store the current Locale in the HTML form,
            // and make the month and day names available in javascript arrays.
            // The form's Language attribute is used as a flag so that this is only
            // done once for each form.
            Form form = pc.getCurrentForm();
            if ((form.getLanguage() == null)
            || (!form.getLanguage().equals(pc.getLocale().toString()))) {
                // Save the locale in the html form as hidden fields so that the
                // same locale can be used to parse returned data.
                pc.write("<input type="hidden" name="_HTMLX_LANGUAGE_" value="" + pc.getLocale().getLanguage() + "">");
                pc.write("<input type="hidden" name="_HTMLX_COUNTRY_"  value="" + pc.getLocale().getCountry()  + "">");
                pc.write("<input type="hidden" name="_HTMLX_VARIANT_"  value="" + pc.getLocale().getVariant()  + "">");
                // Write javascript arrays of month and day names in the locale language
                StringBuffer sb = new StringBuffer(250);
                String javaScriptPath = pc.getJavascriptPath();
                sb.append("var javaScriptPath='");
                sb.append(javaScriptPath);
                sb.append("';");
                java.lang.String dayNames[] = RenderUtil.getDayAbbreviations(pc.getLocale());
                if (dayNames.length != 7) {
                    throw new IllegalStateException("Only locales with 7 days are supported!");
                sb.append("var htmlbDayNames = new Array('");
                for (int i = 0; i < 6; i++) {
                    sb.append(dayNames<i>);
                    sb.append("','");
                sb.append(dayNames[6]);
                sb.append("');n");
                sb.append("var htmlbMonthNames = new Array('");
                java.lang.String monthNames[] = RenderUtil.getMonthNames(pc.getLocale());
                for (int i = 0; i < 11; i++) {
                    sb.append(monthNames<i>);
                    sb.append("','");
                sb.append(monthNames[11]);
                sb.append("');n");
                java.lang.String jscript = sb.toString();
                pc.getDocument().getIncludes().addBodyEndResource(ResourceType.DIRECTJSCRIPT, "HTMLB_INPUTFIELD_DATEHELP", jscript);
                // Set the language in the form so we don't do this again       
                form.setLanguage(pc.getLocale().toString());
            if (writingDebugToConsole) {
                System.out.println("Finished rendering HxInputField (id='" + inf.getId() + "')");
            m_logger.info("Exit:  HxInputFieldRenderer.render()");
        //  Methods to allow the Standard HTMLB InputField to Mimic HxInputField
        //  The key idea here is to use the standard InputField ONLY as a String
        //  field (never Date) so that we have total control over the display format
        //  and then HTMLX looks after ofrmating the string, abd displaying the
        //  help icons, status messages etc.  
         * Render the HTML placed before a HTMLB InputField, an InputField,
         * and the code placed after the InputFIeld, so that it behaves like a
         * HTMLX HxInputField
         * @param field
         * @param pc
        public static InputField mimicRender(HxField hxField, IPageContext pc) {
            HxInputField hxInputField = new HxInputField(hxField, pc.getLocale());
            return mimicRender(hxInputField, pc);
         * Render the HTML placed before a HTMLB InputField, an InputField,
         * and the code placed after the InputFIeld, so that it behaves like a
         * HTMLX HxInputField
         * @param field
         * @param pc
        public static InputField mimicRender(HxInputField hxInputField, IPageContext pc) {
            // Render stuff before InputField
            renderBeforeInputTag(hxInputField, pc);
            // Render InputField
            InputField inputField = new InputField(hxInputField.getId());  
            setUpInputField(hxInputField, inputField, pc);
            // This is a kludge to make a field read only.  It is achieved by
            // adding the flag to the 'width' attribute.  HTMLB then unknowingly
            // adds the flag when it renders the 'width' attribute.
            if (hxInputField.isReadOnly()) {
                inputField.setWidth( inputField.getWidth() + ";" readonly="");
            inputField.render(pc);
            String uniqueName = pc.getParamIdForComponent(inputField);
            String popUpKeyUniqueName = "";
            // If the field has a Pop Up add a hidden field for the Key populated by the Pop Up
            if (hxInputField.isShowPopUp()) {
                InputField keyInputField = new InputField(hxInputField.getId() + "PopUpKey");  
                keyInputField.setVisible(false);
                keyInputField.setValue(hxInputField.getPopUpKeyValue());
                keyInputField.render(pc);
                popUpKeyUniqueName = pc.getParamIdForComponent(keyInputField);
            // Render stuff after InputField
            renderAfterInputTag(hxInputField, pc, uniqueName, popUpKeyUniqueName);
            return inputField;      
         * Render the HTML to be placed before a HTMLB InputField so that it
         * behaves like a HTMLX HxInputField
         * @param field
         * @param pc
        public static void renderBeforeInputTag(HxField field, IPageContext pc) {
            renderBeforeInputTag(new HxInputField(field), pc);
         * Render the HTML to be placed before a HTMLB InputField so that it
         * behaves like a HTMLX HxInputField
         * @param inf
         * @param pc
        public static void renderBeforeInputTag(HxInputField inf, IPageContext pc)
            if (writingDebugToConsole) {
                System.out.println("Start    rendering mimic HxInputField (id='" + inf.getId() + "') ...");
            if (showDateHelp(inf) || showPopUp(inf) || showPatternHint(inf) || showStatusMsg(inf)) {
                pc.write("<table cellspacing="0" cellpadding="0" border="0" id="");
                pc.write(""><tr><td>");
         * Set a HMTLB InputField with the values stored in the HxField.
         * This makes for less code in the JSP, and some versions of the PDK/EP
         * do not support some paramters in the TAG (e.g. Tooltip)
         * @param hxField
         * @param myContext
         * @param pageContext
        public static InputField setUpInputField(HxField hxField, IPageContext pc, PageContext pageContext) {
            Component component = (Component)pageContext.getAttribute(hxField.getId());
            if (!(component instanceof InputField)) {
                String msg =
                    "HxInputFieldRenderer.setUpInputTag() component is not instanceof InputField " +
                    "(hxField.getId()='" + hxField.getId() + "' " +
                    " component.getClass().getName()='" + component.getClass().getName() + "')";
                PortalRuntime.getLogger("htmlx").severe(msg);
                throw new IllegalArgumentException(msg);
            InputField inf = (InputField)pageContext.getAttribute(hxField.getId());
            setUpInputField(hxField, inf, pc);
            return inf;
         * Set a HMTLB InputField with the values in the HxField.
         * This makes for less code in the JSP, and some versions of the PDK/EP
         * do not allow you to set some paramters in the TAG (e.g. Tooltip)
         * @param hxField
         * @param myContext
         * @param pageContext
        public static void setUpInputField(HxField hxField, InputField inf, IPageContext pc) {
            inf.setDisabled(hxField.isDisabled());
            inf.setInvalid(hxField.isInvalid());
            inf.setMaxlength(hxField.getMaxLength());
            inf.setRequired(hxField.isRequired());
            inf.setShowHelp(false);
            inf.setTooltip(hxField.getTooltip());
            inf.setType(DataType.STRING);
            inf.setValue(hxField.getValueAsString(pc.getLocale()));
            inf.setVisible(hxField.isVisible());
            inf.setSize(hxField.getMaxLength());
         * Set a HMTLB InputField with the values stored in the HxField.
         * This makes for less code in the JSP, and some versions of the PDK/EP
         * do not support some paramters in the TAG (e.g. Tooltip)
         * @param hxField
         * @param myContext
         * @param pageContext
        public static void setUpInputField(HxInputField hxInputField, InputField inf, IPageContext pc) {
            inf.setDisabled(hxInputField.isDisabled());
            inf.setInvalid(hxInputField.isInvalid());
            inf.setMaxlength(hxInputField.getMaxlength());
            inf.setRequired(hxInputField.isRequired());
            inf.setShowHelp(false);
            inf.setTooltip(hxInputField.getTooltip());
            inf.setType(DataType.STRING);
            inf.setValue(hxInputField.getPreformattedValueAsString());
            inf.setVisible(hxInputField.isVisible());
            inf.setSize(hxInputField.getSize());
         * Render the HTML to be placed after a HTMLB InputField so that it
         * behaves like a HTMLX HxInputField
         * @param field
         * @param myContext
         * @param pageContext
        public static void renderAfterInputTag(HxField field, IPageContext pc, PageContext pageContext) {
            renderAfterInputTag(new HxInputField(field), pc, pageContext);
         * Render the HTML to be placed after a HTMLB InputField so that it
         * behaves like a HTMLX HxInputField
         * @param inf
         * @param myContext
         * @param pageContext
        public static void renderAfterInputTag(HxInputField inf, IPageContext pc, PageContext pageContext) {
            Component component = (Component)pageContext.getAttribute(inf.getId());
            String uniqueName = pc.getParamIdForComponent(component);
            String popUpKeyUniqueName = "";
            if (inf.isShowPopUp()) {
                component = (Component)pageContext.getAttribute(inf.getId() + "PopUpKey");
                popUpKeyUniqueName = pc.getParamIdForComponent(component);
            renderAfterInputTag(inf, pc, uniqueName, popUpKeyUniqueName);
         * Render the HTML to be placed after a HTMLB InputField so that it
         * behaves like a HTMLX HxInputField
         * @param inf
         * @param pc
         * @param uniqueName
         * @param popUpKeyUniqueName
        public static void renderAfterInputTag(
            HxInputField inf,
            IPageContext pc,
            String       uniqueName,
            String       popUpKeyUniqueName)
            if (showDateHelp(inf)) {
                String dateFormat  = HxLocaleUtil.getSapDatePatternNumber(pc.getLocale());       
                pc.write("</td><td align='left'><button id='");
                   pc.write(uniqueName);
                   pc.write("-btn' type="button" tabindex="-1" ti="-1" class="urEdfHlpDate" onclick="htmlb_showDateHelp(event,'");
                pc.write(uniqueName);
                pc.write("','");
                pc.write(dateFormat);
                pc.write("','1')"></button>");
                   pc.write("<script>htmlb_addTexts('pt_BR',{SAPUR_OCTOBER:"Outubro",SAPUR_MSG_LOADING:"Processo de carga em andamento"," +
                        "SAPUR_SUNDAY_ABBREV:"Do",SAPUR_F4FIELD_TUTOR:"Pressionar F4 para exibir as entradas possíveis"," +
                        "SAPUR_INVALID:"Não válido",SAPUR_FEBRUARY:"Fevereiro",SAPUR_F4FIELD:"F4- campo de entrada"," +
                        "SAPUR_FRIDAY_ABBREV:"6ª",SAPUR_WEDNESDAY_ABBREV:"4ª",SAPUR_MAY:"Maio",SAPUR_MSG_WARNING:"Advertência"," +
                        "SAPUR_DECEMBER:"Dezembro",SAPUR_SEPARATOR:"-",SAPUR_MSG_SUCCESS:"Com êxito",SAPUR_SATURDAY_ABBREV:"Sa"," +
                        "SAPUR_THURSDAY_ABBREV:"5ª",SAPUR_MSG:"{0} {1} {2}",SAPUR_BUTTON_WHL:"{0} - {1} - {2} - {3}",SAPUR_JULY:"Julho"," +
                        "SAPUR_APRIL:"Abril",SAPUR_FIELD_TIME:"Hora",SAPUR_MSG_ERROR:"Erro",SAPUR_REQUIRED:"Necessário"," +
                        "SAPUR_BUTTON_WHL3:"{0} - {1} - {2}",SAPUR_SEPTEMBER:"Setembro",SAPUR_NOVEMBER:"Novembro",SAPUR_AUGUST:"Agosto"," +
                        "SAPUR_JANUARY:"Janeiro",SAPUR_BUTTON:"Botão",SAPUR_FIELD_PW:"Senha",SAPUR_FIELD:"Texto editável"," +
                        "SAPUR_DISABLED:"Não disponível",SAPUR_FIELD_DATE:"Data",SAPUR_MARCH:"Março",SAPUR_FIELD_NUMBER:"N°"," +
                        "SAPUR_MSG_STOP:"Stop",SAPUR_BUTTON_WHL4:"{0} - {1} - {2} - {3}"," +
                        "SAPUR_BUTTON_ENABLED:"Para ativar, utilizar a barra de espaço",SAPUR_TUESDAY_ABBREV:"3ª",SAPUR_READOLNY:""," +
                        "SAPUR_MSG_JUMPKEY:"Pressionar a barra de espaço para navegar para o campo correspondente",SAPUR_JUNE:"Junho"," +
                        "SAPUR_MONDAY_ABBREV:"2ª"});</script>");
            if (showPopUp(inf)) {
                String dateFormat  = HxLocaleUtil.getSapDatePatternNumber(pc.getLocale());       
                pc.write("</td><td align='left'><div class="urEdfHlpSml" onClick="");
                pc.write("htmlxPopUp('");
                pc.write(getPopUpUrl(pc, inf.getPopUpPage()));
                pc.write("', '");
                pc.write(uniqueName);
                pc.write("', '");
                pc.write(popUpKeyUniqueName);
                pc.write("', ");
                pc.write(inf.getPopUpWidth());
                pc.write(", ");
                pc.write(inf.getPopUpHeight());
                pc.write(", '");
                pc.write(inf.getPopUpAttributes());
                pc.write("')">");
                pc.write(" </div>");
            if (showPatternHint(inf)) {
                String pattern        = "";       
                String patternTooltip = "";
                if (DataType.DATE.equals(inf.getType())) {
                    pattern        = HxLocaleUtil.getDatePatternInLocaleLanguage(pc.getLocale());       
                    patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.DatePatternTooltip", pattern);
                else if (DataType.TIME.equals(inf.getType())) {
                    pattern        = HxLocaleUtil.getTimePatternInLocaleLanguage(pc.getLocale());       
                    patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.TimePatternTooltip", pattern);
                    pattern = " " + pattern;
                else if ((inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0)) {
                    pattern = " " + inf.getPatternHint();
                    patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.PatternTooltip", pattern);
                pc.write("</td><td align='left'>");
                pc.write("<span class='sapTxtLeg' title='" + patternTooltip + "'><nobr>");
                pc.write("<font color='666666' face='Microsoft Sans Serif' style='vertical-align:super' size='1'><b>" + pattern + "</b></font>");
                pc.write("</nobr></span>");
            if (showStatusMsg(inf)) {
                if (inf.getStatusMsgPosition().equalsIgnoreCase("RIGHT")) {
                    pc.write("</td><td align='left'>");
                    pc.write("<font color='990000' face='Microsoft Sans Serif' size='1'>");
                else if (inf.getStatusMsgPosition().equalsIgnoreCase("BELOW")) {
                    pc.write("</td></tr><tr>");
                    if (showDateHelp(inf) && showPatternHint(inf)) {
                        pc.write("<td align='left' colspan='3'>");
                    else if (showDateHelp(inf) ^ showPatternHint(inf)) {      // '^' is Exclusive OR (XOR)
                        pc.write("<td align='left' colspan='2'>");
                    else {
                        pc.write("<td align='left'>");
                    pc.write("<font color='990000' face='Microsoft Sans Serif' style='verticle-align:super' size='1'>");
                pc.write("<nobr>" + inf.getStatusMsg() + "</nobr>");
                pc.write("</font>");
            if (showDateHelp(inf) || showPopUp(inf) || showPatternHint(inf) || showStatusMsg(inf)) {
                pc.write("</span></td></tr></table>");
            // Generate code to store the current Locale in the HTML form,
            // and make the month and day names available in javascript arrays.
            // The form's Language attribute is used as a flag so that this is only
            // done once for each form.
            Form form = pc.getCurrentForm();
            if ((form.getLanguage() == null)
            || (!form.getLanguage().equals(pc.getLocale().toString()))) {
                // Save the locale in the html form as hidden fields so that the
                // same locale can be used to parse returned data.
                pc.write("<input type="hidden" name="_HTMLX_LANGUAGE_" value="" + pc.getLocale().getLanguage() + "">");
                pc.write("<input type="hidden" name="_HTMLX_COUNTRY_"  value="" + pc.getLocale().getCountry()  + "">");
                pc.write("<input type="hidden" name="_HTMLX_VARIANT_"  value="" + pc.getLocale().getVariant()  + "">");
                // Write javascript arrays of month and day names in the locale language
                StringBuffer sb = new StringBuffer(250);
                String javaScriptPath = pc.getJavascriptPath();
                sb.append("var javaScriptPath='");
                sb.append(javaScriptPath);
                sb.append("';");
                java.lang.String dayNames[] = RenderUtil.getDayAbbreviations(pc.getLocale());
                if (dayNames.length != 7) {
                    throw new IllegalStateException("Only locales with 7 days are supported!");
                sb.append("var htmlbDayNames = new Array('");
                for (int i = 0; i < 6; i++) {
                    sb.append(dayNames<i>);
                    sb.append("','");
                sb.append(dayNames[6]);
                sb.append("');n");
                sb.append("var htmlbMonthNames = new Array('");
                java.lang.String monthNames[] = RenderUtil.getMonthNames(pc.getLocale());
                for (int i = 0; i < 11; i++) {
                    sb.append(monthNames<i>);
                    sb.append("','");
                sb.append(monthNames[11]);
                sb.append("');n");
                String jscript = sb.toString();
                pc.getDocument().getIncludes().addBodyEndResource(ResourceType.DIRECTJSCRIPT, "HTMLB_INPUTFIELD_DATEHELP", jscript);
                pc.getDocument().getIncludes().addBodyEndResource(ResourceType.DIRECTJSCRIPT, "HTMLX", getHtmlxJavascript());  
                // Set the language in the form so we don't do this again       
                form.setLanguage(pc.getLocale().toString());
            if (writingDebugToConsole) {
                System.out.println("Finished rendering mimic HxInputField (id='" + inf.getId() + "')");
        private static boolean showDateHelp(HxInputField inf) {
            if (DataType.DATE.equals(inf.getType())
            && inf.isShowHelp()
            && !inf.isDisabled()) {
                return true;
            return false;
        private static boolean showPopUp(HxInputField inf) {
            if (!showDateHelp(inf)
            && !inf.isDisabled()
            && inf.isShowPopUp()) {
                return true;
            return false;
        private static boolean showPatternHint(HxInputField inf) {
            boolean isDateOrTime = DataType.DATE.equals(inf.getType()) || DataType.TIME.equals(inf.getType());
            boolean patternHintSet = (inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0);
            if (inf.isShowPatternHint()
            && (isDateOrTime || patternHintSet)) {
                return true;
            return false;
        private static boolean showStatusMsg(HxInputField inf) {
            if (inf.isShowStatusMsg()
            && (inf.getStatusMsg() != null)
            && (inf.getStatusMsg().length() > 0)) {
                return true;
            return false;
        private static String getPopUpUrl(IPageContext pc, String pageName) {
            IPortalComponentRequest request = (IPortalComponentRequest)pc.getRequest();
            IPortalComponentResponse response = (IPortalComponentResponse)pc.getResponse();
            IPortalUrlGenerator portalGen = null;
            IUrlGeneratorService urlGen = (IUrlGeneratorService)request.getService(IUrlGeneratorService.KEY);
            ISpecializedUrlGenerator specUrlGen2 = urlGen.getSpecializedUrlGenerator(IPortalUrlGenerator.KEY);
            if (specUrlGen2 instanceof IPortalUrlGenerator) {
                portalGen = (IPortalUrlGenerator) specUrlGen2;
            // Create the url to the iView
            String url = "";
            if (portalGen != null) {
                // Create the parameters passed to SAP transaction for mesima
                url = portalGen.generatePortalComponentUrl(request, pageName); // "htmlxJarMimicExample.default");
            return url;
        protected static String getHtmlxJavascript() {   
            return "n" +
            "    if(window.document.domain == window.location.hostname) {                         n" +
            "        document.domain = document.domain.substring(document.domain.indexOf('.')+1); n" +
            "    }                                                                                n" +
            "    var popUpTextId;                                                                 n" +
            "    var popUpKeyId;                                                                  n" +
            "    var myPopUp;                                                                     n" +
            "    function setTextField(text) {                                                    n" +
            "        field = document.getElementById(popUpTextId);                                n" +
            "        if (field) {                                                                 n" +
            "            field.value = text;                                                      n" +
            "        }                                                                            n" +
            "        else {                                                                       n" +
            "            alert('Text target field for pop up not found (' + popUpTextId + ')');   n" +
            "        }                                                                            n" +
            "    }                                                                                n" +
            "    function setKeyField(key) {                                                      n" +
            "        field = document.getElementById(popUpKeyId);                                 n" +
            "        if (field) {                                                                 n" +
            "            field.value = key;                                                       n" +
            "        }                                                                            n" +
            "    }                                                                                n" +
            "    function setFields(text, key, close) {                                           n" +
            "        setTextField(text);                                                          n" +
            "        setKeyField(key);                                                            n" +
            "        if (close) {                                                                 n" +
            "            myPopUp.close();                                                         n" +
            "        }                                                                            n" +
            "        return false;                                                                n" +
            "    }                                                                                n" +
            "    function htmlxPopUp(url, textId, keyId, width, height, attributes) {                  n" +
            "        popUpTextId = textId;                                                        n" +
            "        popUpKeyId = keyId;                                                          n" +
            "        if (myPopUp) {                                                               n" +
            "            myPopUp.close();                                                         n" +
            "        }                                                                            n" +
            "        if (event!=null){                                                            n" +
            "            xPos = event.screenX-event.offsetX;                                      n" + 
            "            yPos = event.screenY-event.offsetY;                                      n" +
            "        }                                                                            n" +
            "        if ((xPos+width) > screen.availWidth) {                                      n" +
            "            xPos=screen.availWidth - width - 10;                                     n" +
            "        }                                                                            n" +
            "        if ((yPos+height) > screen.availHeight) {                                    n" +
            "            yPos=screen.availHeight - height - 10;                                   n" +
            "        }                                                                            n" +
            "        sizeAndPos = 'width=' + width + ', height=' + height + ', top=' + yPos + ', left=' + xPos;      n" +
            "        myPopUp = window.open(url, 'PopUp', sizeAndPos + ', ' + attributes); n" +
            "        if (!myPopUp) {                                                              n" +
            "            alert('You may have unrequested popup blocking on.');                    n" +
            "        }                                                                            n" +
            "    }n";   
        //  Methods to assist dubugging JSP pages   
         * @return True if debug messages are being written to the console
        public static boolean isWritingDebugToConsole() {
            return writingDebugToConsole;
         * When an error occurs in a JSP page the line number given in the stack
         * trace is rarely the line that caused the error.  This can make traking
         * down errors in a JSP page can be very difficult.  By writing debug messages
         * to the console every time a field is rendered, it can be much easier to
         * identify the area of code causing a problem.<p>  
         * <b>Do NOT set this in the production release of your application.</b>
         * @param b
        public static void setWritingDebugToConsole(boolean b) {
            writingDebugToConsole = b;
         * Initialise to NOT write debug to the console
        static {
            writingDebugToConsole = false;

    Try these
    [http://help.sap.com/saphelp_nwmobile71/helpdata/en/45/65ad4ee0531aa8e10000000a114a6b/content.htm]
    [http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/content.htm]
    [http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01381.0120/doc/html/koh1278435126915.html]
    Reagards,
    Mouli

  • Why the same function ToolTipText behaves differently in Jar and in Class

    Hi All! In my applet I use two similar statements from javax.swing:
    jListTeaSortSelect.setToolTipText("To stop the alarm just click over here.");
    jProgressBar1.setToolTipText("To stop the alarm just click over here.");
    Both work correctly when I run my applet from classes.
    Problem: When I run it from jar, composed from the same classes, second tool tip does not appear.
    I have no idea on where to get a hint to the solution. Could that be that the problem is caused by other graphical components or by the layout of the container?
    The applet and JAR in question with source code can be found on
    http://www.kobylkin.net/TeaTimer.htm , and the source code is included below in this letter as well..
    Thanks!
    Egor
    I do not include GNU GPL here, for histerical reasons [:-)]
    * TeaTimerJApplet.java
    * Created on 19. Januar 2002, 18:56
    * Tea timer with sound alarm to brew your tea right for the best taste.
    * Copyright Kobylkin Egor 2002. [email protected] www.kobylkin.net
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * as published by the Free Software Foundation; either version 2
    * of the License, or (at your option) any later version.
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.*;
    import java.applet.Applet;
    import java.net.*;
    public class TeaTimerJApplet extends javax.swing.JApplet {
    /** Creates new form TeaTimerJApplet */
    public TeaTimerJApplet() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {//GEN-BEGIN:initComponents
    java.awt.GridBagConstraints gridBagConstraints;
    jListTeaSortSelect = new javax.swing.JList();
    jButtonTimerStart = new javax.swing.JButton();
    jProgressBar1 = new javax.swing.JProgressBar();
    getContentPane().setLayout(new java.awt.GridBagLayout());
    jListTeaSortSelect.setBorder(new
    javax.swing.border.TitledBorder("Select the tea type"));
    jListTeaSortSelect.setModel(new javax.swing.AbstractListModel() {
    String[] strings = { "Test................10sec.", "Green
    tea.........3min.", "Black tea...........4min.", "Black
    tea...........5min.", "Mint, Coffee......8min." };
    public int getSize() { return strings.length; }
    public Object getElementAt(int i) { return strings; }
    jListTeaSortSelect.setToolTipText("To stop the alarm just click
    over here.");
    jListTeaSortSelect.setName("jListTeaSort");
    jListTeaSortSelect.setSelectedIndex(2);
    jListTeaSortSelect.setSelectionBackground(java.awt.Color.yellow);
    jListTeaSortSelect.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jListTeaSortSelect.setAutoscrolls(false);
    jListTeaSortSelect.addMouseListener(new
    java.awt.event.MouseAdapter() {
    public void mousePressed(java.awt.event.MouseEvent evt) {
    jListTeaSortSelectMousePressed(evt);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    getContentPane().add(jListTeaSortSelect, gridBagConstraints);
    jButtonTimerStart.setBackground(java.awt.Color.lightGray);
    jButtonTimerStart.setText("Start the timer");
    jButtonTimerStart.setToolTipText("<html>Visit me at
    www.kobylkin.net <br> Copyright Kobylkin Egor 2002 under GNU GPL</html>");
    jButtonTimerStart.setDoubleBuffered(true);
    jButtonTimerStart.setMaximumSize(new java.awt.Dimension(180, 90));
    jButtonTimerStart.setMinimumSize(new java.awt.Dimension(120, 27));
    jButtonTimerStart.setNextFocusableComponent(jListTeaSortSelect);
    jButtonTimerStart.setPreferredSize(new java.awt.Dimension(140,
    27));
    jButtonTimerStart.addActionListener(new
    java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButtonTimerStartActionPerformed(evt);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    getContentPane().add(jButtonTimerStart, gridBagConstraints);
    jProgressBar1.setToolTipText("To stop the alarm signal just click
    over here.");
    jProgressBar1.setMinimumSize(new java.awt.Dimension(140, 14));
    jProgressBar1.setPreferredSize(new java.awt.Dimension(140, 14));
    jProgressBar1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mousePressed(java.awt.event.MouseEvent evt) {
    jProgressBar1MousePressed(evt);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    getContentPane().add(jProgressBar1, gridBagConstraints);
    }//GEN-END:initComponents
    private void jListTeaSortSelectMousePressed(java.awt.event.MouseEvent
    evt) {//GEN-FIRST:event_jListTeaSortSelectMousePressed
    // Add your handling code here:
    if ( timerIsRunningFlag == false )
    jListTeaSortSelect.setBackground(java.awt.Color.white);
    so.stop();
    }//GEN-LAST:event_jListTeaSortSelectMousePressed
    private void jProgressBar1MousePressed(java.awt.event.MouseEvent evt)
    if ( timerIsRunningFlag == false )
    jListTeaSortSelect.setBackground(java.awt.Color.white);
    so.stop();
    private void
    jButtonTimerStartActionPerformed(java.awt.event.ActionEvent evt)
    {//GEN-FIRST:event_jButtonTimerStartActionPerformed
    //set the controls in dumb state:
    jButtonTimerStart.setEnabled(false);
    jListTeaSortSelect.setEnabled(false);
    jListTeaSortSelect.setBackground(java.awt.Color.white);
    switch ( jListTeaSortSelect.getSelectedIndex() ) {
    case 0 : timerDelay = 500; break; //Test 10 sec.
    case 1 : timerDelay = 9000; break; //Green tea 3 min.
    case 2 : timerDelay = 12000; break; //Black tea 4 min.
    case 3 : timerDelay = 15000; break; //Black tea 5 min.
    case 4 : timerDelay = 24000; break; //Mint tea 8 min.
    // every "timerDelay/100" seconds the progress bar status will be
    set to be -5% less by timerTaskPerformer.
    // After 20 times timerDelay will be less than 5% so the
    timerTaskPerformer fires the alarm.
    timer = new javax.swing.Timer(timerDelay, timerTaskPerformer);
    timer.setRepeats(true);
    timer.start();
    timerIsRunningFlag = true;
    progressBarStatus = 100;
    jProgressBar1.setValue( progressBarStatus );
    jButtonTimerStart.setLabel("Timer started");
    so.stop();
    }//GEN-LAST:event_jButtonTimerStartActionPerformed
    private ActionListener timerTaskPerformer = new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    if (progressBarStatus > 5){ progressBarStatus-=5;
    jProgressBar1.setValue(progressBarStatus);
    }else{
    timer.stop();
    timerIsRunningFlag = false;
    //user alarm actions
    jListTeaSortSelect.setBackground (java.awt.Color.red);
    Toolkit.getDefaultToolkit().beep();
    so=getAudioClip(getCodeBase(), "spacemusic.au");
    so.loop();
    /* "Server not found" IE error.
    open pop-up explorer window to alert user
    try {
    AppletContext ac = getAppletContext();
    ac.showDocument( new URL( getCodeBase() +
    "teaReady.html" ), "_self");
    catch (MalformedURLException exc) {
    showStatus("Cannot find file teaReady.html");
    progressBarStatus = 0;
    jProgressBar1.setValue( progressBarStatus );
    //return to the initial state
    jButtonTimerStart.setText("Start the tea timer");
    jButtonTimerStart.setEnabled(true);
    jListTeaSortSelect.setEnabled(true);
    //Variables declaration
    private int progressBarStatus = 100;
    public boolean timerIsRunningFlag = false;
    public int timerDelay;
    private javax.swing.Timer timer;
    public AudioClip so;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonTimerStart;
    private javax.swing.JList jListTeaSortSelect;
    private javax.swing.JProgressBar jProgressBar1;
    // End of variables declaration//GEN-END:variables

    Hi
    What i understand from u'r problem is that when a jar is created and run under browser, ToolTipText for progress panel is not shown? is so is the case - i had no problems..
    The code given was compiled and created a jar successfully..
    this is how i created the jar..(under WindowsNT and MSIE)
    jar cf TeaTimer.jar TeaTimerJApplet.class
    TeaTimer.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <BODY BGCOLOR="#FFFFFF">
    <APPLET CODE="TeaTimerJApplet" archive="TeaTimer.jar" WIDTH="200" HEIGHT="200">
    </APPLET>
    </BODY>
    </HTML>
    cheers
    Mohan

  • How to share dependant jars across rars & ears / avoid classcast exceptions

    <b>How can one share dependant jars between a ear application and a resource adapter and avoid getting a ClassCastException? </b>
    <P>
    In some appservers(such as Oracle) the resource adapter is the parent of your ear classloader, so a single instance multiple classloader problem doesn't occur. But in some appservers such as BEA Weblogic this isn't the case. Not sure why BEA decided to make resource adapter class loader seperate and not the parent of ear loader...
    <P>
    If I bundle the resource adapter specific classes in the corresponding module archive file, I will get a class cast exception, becos I will have a <i>single instance and multiple class loader situation</i> (assuming resource adapters uses its own classloader).
    <P>
    Second question related to the above: Web logic documentation recommends that we bundle the common files in APP-INF direcotory for embedded resource adapter apps. If I start bundling the resource adapter in an ear file, for every ear app we will have a rar bundled. What about the JNDI names? won't you have to rename the resource adapter differently for each ear so that there is no jndi name clash? Doesn't this defeat the purpose of having one common connector for all apps?
    <P>
    Here is a detailed description of what I want:
    Let say you have a ear file. Let's say there is a common.jar shared between your ear application (say the ejb module uses it), and your resource adapter.
    <P>
    In the case of Oracle's OC4J I can see there won't be any problem of having this common.jar part of the resource adapter(RA). When the RA class loader loads the rar, it makes sure the common.jar files are accessible in the chain of all class loaders it is a parent of. So, the ear loader, ejb loader etc...will have visibility -> hence no class cast exception.
    <p>
    But what do clients do when they want to have their ear deployable across multiple appservers not just oc4j. BEA recently changed their class loader structure...their resource loader is no longer parent of the ear, so the ejb app in the ear doesn't have visibility into common.jar packaged with rar. So, the only solution was to bundle the common.jar file with the ear. But this causes problems, because we can have a situation where certain object instances (that are not serialized or copied) can be shared across class loaders. This ends up in the single instance multiple class loader situation->hence classcastexception.
    <p>
    The only solution I found was to make the common.jar file a shared library. That way only one copy of the class files are there for both the rar and the ear and its visibility is there not only for rar but for ear since it is loaded by the system class loader or shared library class loader (if ther eis one such).
    <P>
    Please convey best practise recommendation.
    Sudhakar

    Pete <[email protected]> wrote:
    Is there a way to have a non-EJB jar at the EJB classloader level ? Sure, just add it to the Class-Path: manifest entry in your ejb.jar.
    Dimitri

  • How to bundle java help class into jar file ?

    Hi, all,
    I have some package in my project, with which I have a java help jar file as classpath, when I run my project, I need the jh.jar file in directory /jar/jh.jar.
    Now, I bundled all my class packages into a jar file, my.jar, together with the /jar directory. When i run my jar file with command:
    java -jar my.jar
    It tells me couldn't find javahelp class.
    What shall I do? How can I create my jar file with the jh.jar?
    Thanks in advance.

    I think you'd be better off just adding the jh.jar as
    a classpath argument and running it like that:
    java -classpath /myjavalibdir/jh.jar -jar myjar.jar
    ...otherwise you're stepping into redistribution of
    binary issues licensing-wise. That won't work either; when you run java with the -jar option, it ignores both the -classpath option and the CLASSPATH environment variable. However, it will see jh.jar automatically if you put it in the <path-to-java>/jre/lib/ext directory. But for distribution purposes, it might be simpler just to combime the contents of jh.jar into myjar.jar (if you use Ant, its <jar> task makes that very easy). Or, you can just run it this way:java -classpath myjar.jar;jar/jh.jar MyMainClassBTW, I don't think redistribution is a problem; otherwise how anyone even use JavaHelp?

  • Regarding JAR files.

    Dear sir,
    I have given the following coding as an assignment from my college.Please help me to solve it.I have to submit in few days. please reply me as soon as possible.
    And assignment is:
    h3. Problem Statement
    You are trapped in a room full of zombies. Luckily the room is pitch black and, while the zombies can't see, you have night vision goggles. To get out though you will have to be careful, since bumping into a zombie is hazardous to your health.
    More specifically, each zombie will have x and y coordinates between 0 and 99 inclusive. You start at (0,0). If you can get to (99,99), you can take an elevator to safety. You may not leave the room any other way. Get there as fast as you can!
    You must implement a method move. This method takes two int[]s, zx and zy, giving the locations of all the zombies, along with ints x and y giving your location. Your method should return "S" to stand still, or "R", "L", "U", or "D" for the four cardinal directions, and "RU", "RD", "LU", or "LD" for the four diagonal directions: {noformat} LU U RU
    L S R
    LD D RD
    {noformat}Moving right increases your x coordinate, while moving down increases your y coordinate.
    After each of your moves, the zombies will all move randomly. Each zombie will chose a random direction (from the 9 including no move) and attempt to move in that direction. If a zombie wants to move outside of the box defined by (0,0)-(99,99) it will stay where it is instead. Note that while the initial locations of all the zombies are distinct, they will not stay that way -- multiple zombies may occupy the same location.
    Each test case will be generated by first choosing a zombie density in [0.05,0.15]. All locations with x or y at least 5 will then contain one initial zombie with probability equal to the density.
    The simulation will be run for a maximum of 10,000 time steps. You may run into zombies at most 10 times -- the 11th one will kill you. If you fail to reach the exit but you manage to stay alive for T time steps, your score will be T. If you make it to the exit at time T, your score will be 30000 - 2 * T plus 1000 per unused life. In other words, you have 10,000 steps to escape, and you get a bonus of 2 points for each time step you don't need to use. Your final score will simply be the average of your individual scores.
    A simple is provided . To use it you need to write a program which communicates via standard IO. Your main method should first read in N, the number of zombies. For each call to move, you should read in N integers for zx, then N integers for zy, and finally two integers for x and y. You should simply output the move you would return. You can run it with something like: {noformat}java -jar Zombie.jar "java Zombie" -delay 1 -seed 1
    {noformat}"java Zombie" is the executable, and should be replaced with whatever command will run your program. The -delay parameter sets the delay in milliseconds between moves. The -seed parameter specifies the random number generator seed (the examples are 1-10). There is also a -novis parameter which causes the simulation to be run with the visualization. Be careful not to output anything other than your moves to standard out. Standard error may be used for debugging purposes"
    "CODING PROVIDED BY COLLEGE"
    import java.util.*;
    import javax.swing.*;
    import java.io.*;
    import java.security.*;
    import java.awt.*;
    import java.awt.event.*;
    public class BrownianZombies extends JFrame{
    int[] zx, zy;
    int x, y;
    int[] idx;
    boolean[][] visited;
    double p;
    Random r;
    int delay = 100;
    boolean novis, history;
    void generate(String seed){
    try{
    r = SecureRandom.getInstance("SHA1PRNG");
    r.setSeed(Integer.parseInt(seed));
    } catch (Exception e) {
    e.printStackTrace();
    int[] tx = new int[10000];
    int[] ty = new int[10000];
    idx = new int[10000];
    visited = new boolean[100][100];
    int ptr = 0;
    p = r.nextDouble()*0.1+0.05;
    for(int i = 0; i<idx.length; i++)idx[i] = i;
    for(int i = 0; i<100; i++)for(int j = 0; j<100; j++){
    if(i >= 5 || j >= 5)if(r.nextDouble() < p){
    tx[ptr] = i;
    ty[ptr] = j;
    ptr++;
    zx = new int[ptr];
    zy = new int[ptr];
    for(int i = 0 ;i<ptr; i++){
    zx[i] = tx;
    zy[i] = ty[i];
    public void move(){
    for(int i = 0; i<zx.length; i++){
    int s = r.nextInt(i+1);
    int t = idx[i];idx[i] = idx[s];idx[s] = t;
    for(int i = 0; i<zx.length; i++){
    int xx = zx[idx[i]] + r.nextInt(3) - 1;
    int yy = zy[idx[i]] + r.nextInt(3) - 1;
    if(xx < 100 && yy < 100 && xx >= 0 && yy >= 0){
    zx[idx[i]] = xx;
    zy[idx[i]] = yy;
    int lives = 10;
    int T;
    public boolean ok(){
    for(int i = 0; i<zx.length; i++)if(x == zx[i] && y == zy[i])lives--;
    return lives >= 0;
    public String checkData(String s){return "";}
    public double runTest(String lt){
    try{
    int time = 10000;
    generate(lt);
    StringBuffer sb = new StringBuffer();
    sb.append(zx.length).append('\n');
    os.write(sb.toString().getBytes());
    os.flush();
    int score = 30000; T = 0;
    if(history)visited[0][0] = true;
    while((x != 99 || y != 99) && T < 10000){
    T++;
    sb.delete(0,sb.length());
    sb.append(zx[0]);
    for(int i = 1; i<zx.length; i++)
    sb.append(' ').append(zx[i]);
    sb.append('\n');
    sb.append(zy[0]);
    for(int i = 1; i<zy.length; i++)
    sb.append(' ').append(zy[i]);
    sb.append('\n').append(x).append(' ').append(y).append('\n');
    os.write(sb.toString().getBytes());
    os.flush();
    String dir = input.next();
    if(dir.equals("S")){
    }else if(dir.equals("R")){
    x++;
    }else if(dir.equals("L")){
    x--;
    }else if(dir.equals("U")){
    y--;
    }else if(dir.equals("D")){
    y++;
    }else if(dir.equals("RU")){
    x++;
    y--;
    }else if(dir.equals("LU")){
    x--;
    y--;
    }else if(dir.equals("RD")){
    x++;
    y++;
    }else if(dir.equals("LD")){
    x--;
    y++;
    }else{
    System.out.println("Invalid Direction: "+dir);
    return 0;
    if(x < 0)x = 0;
    if(y < 0)y = 0;
    if(x == 100)x = 99;
    if(y == 100)y = 99;
    if(!ok()){
    System.out.println("Brains... Score = "+T);
    return T;
    move();
    if(!ok()){
    System.out.println("Brains... Score = "+T);
    return T;
    score -= 2;
    if(!novis){
    if(history)visited[x][y] = true;
    repaint();
    Thread.sleep(delay);
    System.out.println("Score: "+(score + lives * 1000));
    return score + (x != 99 || y != 99 ? 0 : lives * 1000);
    }catch(Exception e){
    e.printStackTrace();
    return 0;
    class Vis extends JPanel{
    public void paint(Graphics g){
    if(zx == null)return;
    Graphics2D g2 = (Graphics2D)g;
    g2.setColor(new Color(200,200,200));
    g2.fillRect(0,0,getWidth(),getHeight());
    Font f = new Font(g2.getFont().getName(),Font.PLAIN,20);
    g2.setFont(f);
    FontMetrics fm = g2.getFontMetrics();
    int th = fm.getAscent();
    int mul = Math.max(1,Math.min((getWidth()-1)/100,(getHeight()-1-2*th)/100));
    int[][] cnt = new int[100][100];
    for(int i = 0; i<zx.length; i++){
    cnt[zx[i]][zy[i]]++;
    for(int i = 0; i<100; i++){
    for(int j = 0; j<100; j++){
    if(cnt[i][j] == 1)g.setColor(Color.red);
    else if(cnt[i][j] > 1)g.setColor(Color.magenta);
    else if(visited[i][j])g.setColor(Color.cyan);
    else g.setColor(Color.white);
    if(i == x && j == y)g.setColor(Color.blue);
    g.fillRect(mul*i+1,2*th+mul*j+1,mul,mul);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    String txt = "Moves Made: "+T;
    g.setColor(Color.black);
    g.drawString(txt,0,th);
    txt = "Lives left : "+lives;
    g.drawString(txt,0,2*th);
    static Process pr;
    static Scanner input;
    static InputStream error;
    static DataOutputStream os;
    public static void main(String[] args) throws IOException{
    BrownianZombies b = new BrownianZombies();
    String exec = null;
    String seed = "1";
    for(int i = 0; i<args.length; i++){
    if(args[i].equals("-delay")){
    b.delay = Integer.parseInt(args[++i]);
    }else if(args[i].equals("-seed")){
    seed = args[++i];
    }else if(args[i].equals("-novis")){
    b.novis = true;
    }else if(args[i].equals("-history")){
    b.history = true;
    }else{
    exec = args[i];
    if(exec == null){
    System.out.println("Please enter an executable");
    System.exit(1);
    //for(int i = 0; i<b.zx.length; i++){
    //System.out.println(i+" "+b.zx[i]+" "+b.zy[i]);
    if(!b.novis){
    b.add(b.new Vis());
    b.setSize(450,450);
    b.setVisible(true);
    b.addWindowListener(new Closer());
    pr = Runtime.getRuntime().exec(args[0]);
    input = new Scanner(pr.getInputStream());
    error = pr.getErrorStream();
    os = new DataOutputStream(pr.getOutputStream());
    new ErrorReader().start();
    b.runTest(seed);
    pr.destroy();
    public String displayTestCase(String s){
    generate(s);
    return "p = "+p;
    public double[] score(double[][] d){
    double[] ret = new double[d.length];
    for(int i = 0; i<ret.length; i++)
    for(int j = 0; j<d[0].length; j++)
    ret[i] += d[i][j];
    return ret;
    static class ErrorReader extends Thread{
    public void run(){
    try{
    byte[] ch = new byte[50000];
    int read;
    while((read = error.read(ch)) > 0){
    String s = new String(ch,0,read);
    //System.out.println("err: "+s+" "+s.endsWith("\n"));
    System.out.print(s);
    System.out.println();
    }catch(Exception e){
    //System.err.println("Failed to read from stderr");
    static class Closer implements WindowListener{
    public void windowActivated(WindowEvent e){}
    public void windowDeactivated(WindowEvent e){}
    public void windowOpened(WindowEvent e){}
    public void windowClosing(WindowEvent e){
    pr.destroy();
    System.exit(0);
    public void windowClosed(WindowEvent e){}
    public void windowIconified(WindowEvent e) {}
    public void windowDeiconified(WindowEvent e) {}

    haytony, let me give you a word of advice. The more work you show, the more work the volunteers are often willing to give. For instance, if you've done a ton of research, wrote most of your own code but were stuck on specific points and posted this, the folks here will bend over backwards to lend you a strong hand to help you as much as possible.
    If on the other hand, you simply post your entire assignment and don't show that you've done one speck of work, often we ignore you at best or ridicule you at worst.
    C'mon, it's up to you. Step up to the plate and show us your work, and your worthiness for help. If you can prove yourself to be a hard-working studious type, then I personally will do all in my upmost to help you. If on the other hand you repeatedly spam these forums with pathetic attempts at getting others to do homework where there is absolutely no evidence that you have done a lick of work yourself, then I will ridicule, flame, and bother you to know end.
    So which is it to be? Again, it's all up to you. Time to go to bat.

  • Dinamyc class loading and jar files

    I'm new to java. I would like to load some plugins in my application (it's going to be packaged as a jar at the end). I managed to find some dinamyc class loading examples but they search for the classes to load in a directory.
    This is the code:
        public static void main(String[] args) {
            File pluginDirectory = new File("src/pluginsreloaded/plugins");
            if (!pluginDirectory.exists()) {            // the plugin directory does not exist
                System.out.println("The plugins directory does not exist!");           
                return;
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".class");
            String[] pluginFiles = pluginDirectory.list(filter);
            for (int i = 0; i < pluginFiles.length; i++) {
                if (pluginFiles.indexOf("$") == -1) {
    System.out.println("Loading: " + pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    IPlugin plugin = pm.loadPlugin(pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    System.out.println(plugin.description());
    protected static IPlugin loadPlugin(String name) {
            // Query the plugin list for the plugin
            PluginFactory _plugin = (PluginFactory) pluginList.get(name);
            if (_plugin == null) {          // the plugin is not loaded
                try {
                    Class.forName("pluginsReloaded.plugins." + name);
                    // The plugin makes an entry in the plugin list
                    // when loaded
                    _plugin = (PluginFactory) pluginList.get(name);
                    if (_plugin == null) {
                        return null;
                } catch (ClassNotFoundException e) {
                    System.out.println("Plugin " + name + " not found!");
            return _plugin.create();
        }IPlugin is an interface. I am using netbeans 5.0. The error I get is this:
    Exception in thread "main" java.lang.NoClassDefFoundError: pluginsReloaded/plugins/plugin1 (wrong name: pluginsreloaded/plugins/plugin1)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at pluginsreloaded.PluginManager.loadPlugin(PluginManager.java:30)
            at pluginsreloaded.Main.main(Main.java:44)
    Java Result: 1As far as I can see it can't find the class. My question is how can I load the class/where can I find it?
    Thanks.

    You can use the java.util.jar.JarFile class to enumerate the contents of a jar. It's not good practice to search for plugins in this way though. A plugin may well involve serveral classes, which don't all have to be internal. Furthermore its wise to avoid any comitment about the mechaism by which class files are to be fetched. You might want to do it remotely, some time, or load them from a database.
    What seesms to be the standard approach is to put a list of plugin classes into the jar as a text file.
    Plugins for a given purpose usually implement some specified interface, or extend some abstract class to which their objects can be cast once loaded (without this they aren't really much use).
    Say your plugins implment org.myorg.WidgetFactory then you put a list of them, one fully qualified name to a line, in a file or jar entry called META-INF/services/org.myorg.WidgetFactory. You framework picks up all such files from the classpath using ClassLoader.getResources() and loads all the classes whose names if finds, hence you can add new sets of plugins just by adding a new jar or class directory to the class path.

  • Import a external jar in web dynpro project

    hi,
    u have to add two Public Parts one for assembly and one for  Compile,.
    chk this out,
    /people/bala.krishnan2/blog/2006/09/25/bid-adieu-to-bots--using-captchas
    1. Create an External Library DC
    2. Copy all of the Jars  needed to the libraries folder of this DC
    3. Create two Public Parts (right click on the jar files in Package Explorer)
          i) compilePart (with purpose compilation)
          ii) assemblyPart (with purpose assembly)
    4 Create a new DC of type J2EE Server Component / Library
    5. Add a Used DC to the J2EE Library, reference the compilePart from previous step, and set Dependency type to Build
    6. Add another Used DC, reference the assemblePart, this time select both Build and Runtime Dependency Types
    7. Build and deploy.
    Regards
    Jay

    Hi Peoples...
    Actualy, i use NWDS 7.1 EHP, and don't have some option that you describe above. It's a little different.
    I've created the public parts adding it in Development Infrastructure perspective, but this never worked. Than i tried to do what satish jhariya post above. In my External Library DC i publish as archive the jar files, one as compilation and other as assemply. Then my component works.
    Thanks for all the replies.
    There are some difference about the way that you include a public part?

Maybe you are looking for

  • Saving Edited pics from the project bin

    I am a little rusty as I havent used my PSE 9 for quite some time and I cant remember how to save the files that have been edited in the project bin.  I click on File - Save As........But it will only allow me to save one pic at a time.  Thats it.  C

  • A suggestion to inhance nokia phones popularity

    Hello Im one of the fans of nokia in iran but I think the most important reason that nokia devices specially lumia series cant be sold very good in iran is than unfortunately now although after almost three years there is very limited expert to creat

  • How to locate photos using keywords in sub-categories?

    Is there a way to locate your photos according to the sub-categories in keywords, such as under "animals" I have "wild" and "domestic"? When I search for them with the inspector, I only can access the main category. Message was edited by: Host <to cl

  • Burning in Disc-At-One (gapless) mode?

    Hi all - the last time I asked this (about two years ago) I was told that iTunes does not support burning audio CD's in such a way that there are no gaps between tracks - usually achievable through disc-at-once mode. But that was two years ago. Do th

  • Ipod getting unknown error code when plugging it in to itunes 9

    My ipod was restored with itunes 9, but after it's done it wont get recognized with itunes. Itunes says there is a unknown error code(OxE800000A). How do i get itunes to recognize my ipod. I have 3.1.2 firmware, its a 2nd generation, 8gb.