JSPs packaged in a JAR

Does anyone know how I can address from within a web application JSPs that are in a JAR library? I have a bunch of java classes and a couple of JSPs that I want to distribute as a JAR library. So, within a web application (or a WAR) this would live in the /WEB-INF/lib/mylibrary.jar.
Any help would be greatly appreciated.
Marc

Basically, I have a runtime library that I plan to distribute for reuse in multiple applications. I would like folks to only have to include the jar in their wars to access both the class files and the JSPs. Otherwise, they will have to include the jar and separately include the JSPs in their projects. Not the end of the world obviously, but just another opportunity for mix-ups.
Marc

Similar Messages

  • Problem with importing jsp packages

    Hi guys. I'm having a problem compiling a class that imports jsp packages.
    I'm getting errors along the lines of:
    C:\>javac HelloTag.java
    HelloTag.java:4: package javax.servlet.jsp does not exist
    import javax.servlet.jsp.*;
    ^
    HelloTag.java:5: package javax.servlet.jsp.tagext does not exist
    import javax.servlet.jsp.tagext.*;
    - I've copied jsp-api.jar and servlet-api.jar to a folder that's in my path: C:\Program Files\Java\jre1.5.0_03\lib\ext
    Any suggestion?
    Thanks.

    U have to add the path into the classpath
    set CLASSPATH=%CLASSPATH%;jsp-api.jar ....
    the compile in the same cmd window
    Do not use the CLASSPATH environment variable. Use the -classpath option while compiling and specify the path to your jar file.
    javac -classpath <path to jar file> filename.javacheers,
    ram.

  • Trying to use ord.jdom package with a jar - it's not working...

    Guys, I'm trying to build a Swing app that uses jdom classes and interfaces. I built the app in NetBeans, and to get the jdom packages to work, I had to mount the jdom.jar. Then suddenly, I had no errors using the jdom classes Document, Element, SAXBuilder etc. I have the program running perfectly inside the netbeans interface.
    Now, how do I get everything working together in a JAR?
    Here's the starts of the respective files:
    * CTATool.java
    * Created on January 3, 2004, 1:23 PM
    package CTATool;
    * @author  jason_michael_trk
    public class CTATool extends javax.swing.JFrame
        /** Creates new form CTATool */
        public CTATool()
            initComponents();...
    * FileWriterXML.java
    * Created on March 5, 2004, 10:06 AM
    package CTATool;
    import org.jdom.*;
    import org.jdom.output.*;
    import java.io.*;
    * @author  Jason L Michael
    public class FileWriterXML
        private Document doc;
        private FileWriter fw;
        private File f;
    I need to include in the JAR the org.jdom package. How do I do this?
    Here's the manifest I am using cirrently:
    Manifest-Version: 1.0
    Created-By: NetBeans IDE
    Specified-By: CTATool.V2.jarContent
    Main-Class: CTATool.CTAToolThe jar includes the CTATool.class file, the FileWriterXML.class file and the jdom.jar.
    I'm getting the following errors, when I attempt to execute the CTATool.V2.jar:
    java.lang.NoClassDefFoundError: org/jdom/JDOMException
            at CTATool.CTATool.saveStatsAndExit(CTATool.java:1457)
            at CTATool.CTATool.quitMenuItemActionPerformed(CTATool.java:1450)
            at CTATool.CTATool.access$400(CTATool.java:13)
            at CTATool.CTATool$5.actionPerformed(CTATool.java:157)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
            at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
            at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
            at java.awt.Component.processMouseEvent(Component.java:5134)
            at java.awt.Component.processEvent(Component.java:4931)
            at java.awt.Container.processEvent(Container.java:1566)
            at java.awt.Component.dispatchEventImpl(Component.java:3639)
            at java.awt.Container.dispatchEventImpl(Container.java:1623)
            at java.awt.Component.dispatchEvent(Component.java:3480)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
            at java.awt.Container.dispatchEventImpl(Container.java:1609)
            at java.awt.Window.dispatchEventImpl(Window.java:1590)
            at java.awt.Component.dispatchEvent(Component.java:3480)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)this is right when the FileWriterXML class is created and ran.
    Help??!??Thanks in advance!
    chewy

    I think I figured this out, if it helps anyone...
    You have to wrap up all of YOUR classes into a jar, and have a manifest entry that specifies:
    Class-Path: jdom.jar
    Next, you have to put the two together (I used a self-extracting zip file. It contained MyApp.jar and jdom.jar).
    when the client extracts it onto their desktop and double clicks on MyApp.jar, it works perfectly.
    I don't think there's an easy way to package the jdom.jar in my jar and make this work.
    Hope this helps some other wary traveler!
    chewy

  • Extracting class files of a certain package from a jar.

    Hi,
    I want to extract all the class files belonging to a certain package from a JAR file containing class files belonging to a different packages.
    Can I do this using the jar tool, or use some other unzipping tool?
    If it is best to use an unzipping tool which one can I use for windows?
    Thanks,
    Niranjan.

    jar xf file.jar path/to/dir
    For more info see http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/jar.html.

  • Need help: how to make a package into a jar file?

    I tried to make a package into a jar file by using:
    jar cf a.jar packagedirectory
    But when I import one class of this package in an other application, by using:
    javac -cp path\a.jar; app.java
    the compliler can not find the calss.
    The interesting thing is if I do not put the package into the jar file, it works well.
    Here is my sample code under path D:\b\b1
    package b1;
    public class Son
         int x = 10;
         public Son(){
         public int getX(){
              return x;
    and the application code under path d:\b
    import b1.Son;
    public class Father
         public Father(){
         public static void main(String[] args)
              Son son = new Son();
              System.out.println("Hello World!"+son.getX());
    Thanks for any advise.
    Xin Cheng

    You must make sure that you are in the right directory
    when you do your jar command to create the archive.
    [home/trejkaz/proj/test/classes]% jar -cf a.jar
    path/to/package/*.class
    Thank you very much.
    Yes, I did as what you said, but it does not work.
    Here is what I did:
    1. Edit Father.java in D:\b
    2. Edit Son.java in D:\b\b1
    3. Compile Son.java
    4. Complie Father.java
    5. Make the a.jar by
    command jar cf a.jar D:\b\b1\ (I cheked the content of the a.jar, it seems right.)
    a.jar is in directory D:\b
    6. Delete Son.class in D:\b\b1
    7. Run Father.class by
    command: java -classpath D:\b\a.jar; Father
    error message is: Exception in thread "main" java.lang.NoClassDefFoundError: b1/Son
    at Father.main(Father.java:11)
    What is the problem?
    Thanks again.

  • Packaging jsp's in diffrent jar's!

    Hello
    I'm new to JSF and would like to start a project based on JSF 1.2. As my application invoves lots of business modules, need to package each module separately.Means backing bean,resourcebundle and jsp's will be packaged separately for each module.
    Unfortunately system fails to load jsp if I put it in jar file (this jar is available in web-inf/lib) instead of web application war file directly.
    Can anybody suggest me any solution on the same.
    Thanks
    Jobinesh

    Thank you very much RaymondDeCampo for your quick response.
    But I happened to see Tapestry supports this kind of requirement. There we can keep jsp's separately under different projects and war file would contain different artefacts(jars) cotaining jsps.
    So I assume that somebody might have already faced this situation.
    One work around would be to copy th jsp's to web app target folder as part of build process(ant/maven). But looking for more elegant solution.
    Can anybody share their knowledge on the same
    Thanks
    Jobinesh

  • JSP import fails unless Jars are included in the PAR

    Hello,
    We have a simple EP6 iView for displaying the Universal Worklist entries (UWL) using a JSPDynPage.
    We import the UWL library symbols and compile/use them in the Java code without problems (e.g. import com.sap.netweaver.bc.uwl.Item; )
    The following entry is made in the portalapp.xml file to make sure the UWL symbols are found at runtime:
         <property name="ServicesReference" value="SAPJ2EE::library:tckmcbc.uwl~api"/>     
    The problem occurs when we try to import the UWL symbols into our JSP with this code:
         <%@ page import="com.sap.netweaver.bc.uwl.Item" %>
    The UWL symbols are just not found.  Here are the exception headers:
    #1#com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Resource
    Component : pcd:portal_content/MikesFolder/com.lds.mlp.MikesTest1
    #1#com.sapportals.portal.prt.servlets_jsp.server.compiler.CompilingException: Error occurs during the rendering of jsp component
    Caused by: com.sapportals.portal.prt.servlets_jsp.server.compiler.CompilingException: D:/usr/sap/EP1/JC00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/mikestest1/work/pagelet/_sapportalsjsp_helloiviewpage.java:22: package com.sap.netweaver.bc.uwl does not exist
    import com.sap.netweaver.bc.uwl.Item;
                                    ^
    1 error
    Now if I add the bc.uwl.service.api_api.jar into PORTAL-INFlib everything is fine.  However this seems like such a 'hack'.  We really shouldn't be distributing a system file in our PAR.
    This person seems to have had the same problem with the system mail jars ( JSP MAIL ERROR ).
    Can anyone please shed some light on this problem?  Do we really have to distribute the system jars to make this JSP import work properly?
    Thanks & Cheers,
    Mike Pastor
    "always generous with points"

    Hi,
    This is exactly the portalapp.xml of the sap application com.sap.netweaver.bc.uwl.par
    check out the difference between this and yours?
    Dont miss out on anything important here. I think it should work.
    If you are still facing problem only while using in jsp I have a cure.
    Write a clean java class in your app which queries the apis in this jar.
    Also add sharing reference to this application in your portalapp.xml. Query your class in your jsp rather than the "standard jar"
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <registry>
        <entry path="/runtime/hooks/deployment/UniversalWorklistDeploymentHook" name="UniversalWorklistDeploymentHook" type="service"/>
      </registry>
      <application-config>
        <property name="startup" value="true"/>
        <property name="releasable" value="true"/>
        <property name="ServicesReference" value="SAPJ2EE::library:tckmcbc.uwl~api,SAPJ2EE::service:webdynpro,com.sap.portal.runtime.system.inqmy, com.sap.portal.ivs.connectorservice,com.sap.portal.ivs.systemlandscapeservice, urlgenerator, com.sap.portal.usermapping, usermanagement, com.sap.portal.runtime.application.rfcengine,com.sap.portal.runtime.config,knowledgemanagement"/>
        <property name="PreservedConfigPaths" value=""/>
        <property name="Vendor" value="sap.com"/>
        <property name="SecurityArea" value="NetWeaver.KMC"/>
      </application-config>
      <components/>
      <services>
        <service name="com.sap.netweaver.bc.uwl" alias="UniversalWorklistService">
          <service-config>
            <property name="className" value="com.sap.netweaver.bc.uwl.core.portal.UWLPortalService"/>
            <property name="classNameFactory" value=""/>
            <property name="classNameManager" value=""/>
            <property name="poolFactory" value="0"/>
            <property name="startup" value="true"/>
            <property name="SafetyLevel" value="low_safety"/>
          </service-config>
        </service>
        <service name="UniversalWorklistDeploymentHook">
          <service-config>
            <property name="className" value="com.sap.netweaver.bc.uwl.core.portal.UWLDeploymentHook"/>
            <property name="classNameFactory" value=""/>
            <property name="classNameManager" value=""/>
            <property name="poolFactory" value="0"/>
            <property name="startup" value="true"/>
            <property name="SafetyLevel" value="low_safety"/>
          </service-config>
        </service>
      </services>
    </application>

  • Duke$ - Multiple packages in one jar... again

    My jar contains 2 packages.
    One is my own, the other one is the JNIRegistry from Ice. (Excellent for Windows. Download it at: http://www.trustice.com/java/jnireg/index.shtml )
    My application starts from the jar file and works just fine, but as soon as one of my classes tries to import/load a class from the com-package, the NoClassDefFoundError exception is thrown.
    I created the jarfile in my app-folder by using:
    jar cfm myJarFile.jar manifest.mf myPackage com
    This is the folder tree:
    C:\
    |
    |-app
    |
    |--com (folder)
    |
    |--myPackage (folder)
    |
    |--manifest.mf
    I have checked the contents of the jarfile, nothing is missing.
    This is the manifest file:
    Main-Class: myPackage.App
    I am sure there must be a way around this... The closest solution I have found was at:
    http://forum.java.sun.com/thread.jsp?forum=22&thread=30891
    It says specify each class you want to import from the other package, for example dont use
    import com.ice.jni.registry.*;
    but
    import com.ice.jni.registry.Registry;
    import com.ice.jni.registry.RegistryKey;
    import com.ice.jni.registry.RegStringValue;
    So I did. Nothing changed, still the NoClassDefFoundError
    Any help?
    Thanks in advance

    Hey guys,
    This is how you do it. I have an example here for you to follow:
    -----Test.java
    package com.test;
    import another.one.*; // note * is ok to use!
    class Test
         public static void main(String[] args)
              System.out.println("Hello from Test!");
              Target.main(null);
    }------Target.java
    package another.one;
    public class Target
         public static void main(String[] args)
              System.out.println("Hello from Target!");
    }place files like so:
    {path}/com/test/Test.java
    {path}/another/one/Target.java
    compile classes, then create a manifest:
    ---manifest.txt
    Main-Class: com.test.Test
    {a blank line here}
    place at:
    {path}manifest.txt
    now create jar;
    {path}> jar cmf manifest.txt myJar.jar com/ another/
    and enjoy ;-) java -jar myJar.jar
    -Ron

  • JSP Exception after making JAR

    Hi,
    I'm getting this exception while I package my java class files and properties files as a jar and put it in library. I'm using struts framework which extensively uses tiles. After packaging I dont have any files in the classes directory but all the files are in the library.
    while I debug it goes to Action classes and it executes JSPs so it was able to refer classes properly. But failes in some taglibs.
    Any help would apprieciated.
    ServletException in:/layout/channelpage_enhanced.jsp] null' javax.servlet.ServletException at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843) at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776) at org.apache.jsp.layout.channelpage_005fenhanced_jsp._jspService(channelpage_005fenhanced_jsp.java:1373) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:602) at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137) at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177) at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756) at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881) at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473) at org.apache.jsp.layout.standard_005ftemplate_jsp._jspService(standard_005ftemplate_jsp.java:867) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069) at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274) at

    Instead of building your class files into a jar you might want to consider building the entire web application into a war file for deployment. I do this even for deployment to my local test server just to keep things more similar between my local server and the deployment server.
    This is an excerpt from my ant build
        <target name="build.war">
            <echo message="Building the war file for the web application"/>
            <war
                 destfile="${p.app.jar.dir}/appname/WarFile.war"
                 webxml="${web.module.web-inf.dir}/web.xml">
                <fileset dir="${web.module.resource.dir}">
                    <include name="*.*"/>
                </fileset>
                <classes dir="${web.module.classes.dir}"/>
                <fileset dir="${p.app.jar.dir}/appname">
                    <include name="*.jar"/>
                </fileset>
                <fileset dir="${web.module.web-inf.dir}">
                    <include name="*.*"/>
                </fileset>
                <manifest>
                    <attribute name="Class-Path" value="Service-client.jar"/>
                </manifest>
            </war>
        </target>Just a thought your milage may of course vary.
    PS.

  • Error compiling JSP packages

    Please help.
    I have downloaded the J2EE package - Server, Tutorial, etc. I am trying to get a BASIC jsp page with a single class to compile, but haven't had any luck.
    Server error message is:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    No Java compiler was found to compile the generated source for the JSP.
    This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
    to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
    If using an alternate Java compiler, please check its installation and access path.
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:348)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:424)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
         etc, etc, etc.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Server log shows:
    [#|2004-04-20T15:13:27.286-0500|SEVERE|j2ee-appserver1.4|org.apache.jasper.compiler.Compiler|_ThreadID=12;|Env: Compile: javaFileName=/C:/Sun/AppServer/domains/domain1/generated/jsp/j2ee-modules/default-web-module-server//org/apache/jsp/ch06\ch06_jsp.java
    classpath=C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\default-web-module-server;/C:/Sun/AppServer/lib/install/applications/__xa/
    cp=C:\Sun\AppServer\lib\commons-launcher.jar;C:\Sun\AppServer\jdk\lib\tools.jar;C:\Sun\AppServer\lib\admin-cli.jar;C:\Sun\AppServer\lib\appserv-admin.jar;C:\Sun\AppServer\lib\appserv-upgrade.jar;C:\Sun\AppServer\lib\appserv-ext.jar;C:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\lib\appserv-cmp.jar;C:\Sun\AppServer\lib\appserv-jstl.jar;C:\Sun\AppServer\lib\j2ee-svc.jar;C:\Sun\AppServer\lib\commons-logging.jar;C:\Sun\AppServer\lib\activation.jar;C:\Sun\AppServer\lib\mail.jar;C:\Sun\AppServer\lib\jaxr-api.jar;C:\Sun\AppServer\lib\jaxr-impl.jar;C:\Sun\AppServer\lib\jax-qname.jar;C:\Sun\AppServer\lib\jaxrpc-api.jar;C:\Sun\AppServer\lib\jaxrpc-impl.jar;C:\Sun\AppServer\lib\relaxngDatatype.jar;C:\Sun\AppServer\lib\xsdlib.jar;C:\Sun\AppServer\lib\saaj-api.jar;C:\Sun\AppServer\lib\saaj-impl.jar;C:\Sun\AppServer\lib\appserv-rt.jar;C:\Sun\AppServer\lib\tools.jar;C:\Sun\AppServer\jdk/lib/tools.jar;C:\Sun\AppServer/lib/install/applications/jmsra/imqjmsra.jar;C:\Sun\AppServer\imq\lib/imq.jar;C:\Sun\AppServer\imq\lib/jaxm-api.jar;C:\Sun\AppServer\imq\lib/imqadmin.jar;C:\Sun\AppServer\imq\lib/imqutil.jar;C:\Sun\AppServer\imq\lib/fscontext.jar;C:\Sun\AppServer\imq\lib/providerutil.jar;C:\Sun\AppServer/lib/ant/lib/ant.jar;C:\Sun\AppServer/pointbase/lib/pbclient.jar;C:\Sun\AppServer/pointbase/lib/pbembedded.jar
    cp=C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\default-web-module-server
    cp=C:\Sun\AppServer\lib\install\applications\__xa
    extension dir=C:\Sun\AppServer\jdk/jre/lib/ext;C:\Sun\AppServer\domains\domain1/lib/ext
    work dir=C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\default-web-module-server
    srcDir=C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\default-web-module-server
    include=org/apache/jsp/ch06/ch06_jsp.java
    |#]
    [#|2004-04-20T15:13:27.286-0500|SEVERE|j2ee-appserver1.4|org.apache.jasper.compiler.Compiler|_ThreadID=12;|Error compiling file: /C:/Sun/AppServer/domains/domain1/generated/jsp/j2ee-modules/default-web-module-server//org/apache/jsp/ch06\ch06_jsp.java     [javac] Compiling 1 source file
    [javac] C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\default-web-module-server\org\apache\jsp\ch06\ch06_jsp.java:6: package ch06a does not exist
    [javac] import ch06a.ch06class; I have also tried "import ch06a.*" with the same results.
    [javac] ^
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Autoexec.bat reads:
    SET PATH=C:\Sun\AppServer\bin;C:\Sun\AppServer\jdk\bin;c:\Sun\AppServer\share\bin;c:\Sun\AppServer\jdk\jre\bin;
    SET JAVA_HOME=c:\Sun\AppServer\jdk;
    SET J2EE_HOME=C:\Sun\AppServer;
    SET CLASSPATH=C:\Sun\AppServer\lib\j2ee.jar;c:\Sun\AppServer\jdk\lib\tools.jar;c:\Sun\AppServer\domains\domain1\lib\classes;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    I am developing the jsp in c:\Sun\AppServer\domains\domain1\docroot\ch06 (I know that I shouldn't, but I am trying anything at this point).
    ch06 structure is
    |-WEB-INF
    |-classes
    | |-ch06a
    | |-ch06class.class
    |-lib
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ch06.jsp:
    <%@ page import="ch06a.*" %>
    <HTML>
         </HEAD>
              <TITLE>Using a JavaBean</TITLE>
         <HEAD>
         <BODY>
              <H3>Using a JavaBean</H3>
              <% ch06class messager = new ch06class(); %>
              The message is: <%= messager.msg() %>
         </BODY>
    </HTML>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ch06class.java:
    package ch06a;
    public class ch06class{
         public ch06class(){
         public String msg(){
              return "Hello from JSP!";
    Please let me know if I can supply anymore information.
    Thanks

    Make sure have the latest version of the application server. The previous release had a bug as described in this thread:
    http://forum.java.sun.com/thread.jsp?forum=136&thread=473280
    Here is a reply from that thread from one of the Web container engineers:
    The error message about the missing Java compiler is misleading, and is being caused by a bug in the way compilation error messages are being propagated.
    This problem has been fixed in the latest Appserver 8.0 PE release.
    I think your JSP fails to compile because of an error in your JSP. Your appserver log should contain the real compilation error. Can you check?
    BTW, the date example describe in this chapter does contain a class file:
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro2.html#wp84418

  • Include directive to include a JSP file from a JAR file

    I have an Eclipse project in which I have placed a JSP file in the package structure with the rest of my code. This is in fact only a code snippet page, not a full blown JSP file.
    I have a second project that is a Dynamic Web Project in Eclipse that incorporates the first project as a JAR in the /WEB-INF/lib directory.
    In this project I have a JSP file and I want to include the JSP file embedded in that JAR file.
    How do I do that?
    I'm thinking the only real solution is to rewrite the snippet portion as a custom tag.

    The JSP fragment page in question is actually a HTML form page. It is a form to be used specifically by a particular servlet. That is why they are "bundled" together in the same project, in the same package structure.
    I have multiple web applications that I want to include that form/servlet, so it gets added to these projects in the /WEB-INF/lib folder as a JAR library. But I don't want to recreate the form over and over again for each application. It would be nice if I could write a JSP page that wraps the fragment using an include directive to bring that fragment into the new page.
    So to do that with any other fragment I would write:
    <%@ include file="/WEB-INF/jsp/SOME_FORM.jsp" %>
    which works great if my fragment page is in the /WEB-INF/jsp subfolder. But if I want to access the JSP fragment as it is bundled in a JAR file, this:
    <%@ include file="/WEB-INF/lib/FORM.jar/SOME_FORM.jsp" %>
    doesn't work so good. It's just all wrong.
    I was wondering how I could just write one include statement to get what I need. There are work-arounds galore, but I thought if I could get this working it would be the simplest solution overall.

  • My app works in IDE but not when packaged as a JAR, advice please?

    Hello,
    I've written my application which seems to work perfectly in my IDE, however when I package the application into a JAR, the JavaVM isn't happy with it. When executed, the JVM crashes somewhere early in my program (I'm guessing when it's loading resources) and I get a nice crash dialog from my OS describing some low level stuff.
    So my reason for posting is to gather some advice or guidance on how to tackle this. Is there a simple way to debug a program when it's in JAR form?
    Any comments will be welcomed! Thanks.
    CRASH INFO - just in case it's useful!! :)
    EXC_BAD_INSTRUCTON (0x0002)
    0x0000000D
    Thread 0 Crashed:
    0    JVM_RaiseSignal + 595867
    1    JVM_RaiseSignal + 596054
    2    JNI_CreateJavaVM_Impl + 49220
    3    JVM_Write + 18645
    4    callback + 317
    5    0 + 25151061
    6    __CFRunLoopDoObservers + 342
    7    CFRunLoopRunSpecific + 1548
    8    CFRunLoopRunInMode + 61
    9    0x1000 + 14040

    Those links you posted proved very useful. Using OS dumps a log file which points out an offending library. After a bit of googling, I manage to found out that it was coming from the SWT framework which my app is built on. I've written tons of SWT apps before but I've no idea why this one get upset when I run it?
    I've since took the time to compile and run a Windows & Linux version and they both work perfectly.
    Thanks for the help on this and judging my current situation I think it would be best to speak to the Eclipse/SWT people as this problem has gone slightly 'off-topic' :)

  • Using a UNIX shell script to run a Java program (packaged in a JAR)

    Hi,
    I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
    Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
    loggedinuser="$(whoami)"
    CFG_DIR="`dirname $0`"
    EXIT_STATUS=${SUCCESS}
    export PATH=/opt/java1.3/bin:$PATH
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIR
    java -classpath $
    EXIT_STATUS=$?
    cd $OLDDIR
    echo $EXIT_STATUS
    exit $EXIT_STATUS

    Hi,
    I have an application (very small) that connects to
    our database. It needs to run in our UNIX environment
    so I've been working on a shell script to set the
    class path and call the JAR file.
    #!/bin/sh
    exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
    CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
    cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
    echo $EXIT_STATUS
    exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
    Harald.

  • Packages in separate Jars causes classpath error

    For the purposes of easy-updating and allowing developers to work on one part of a system without interfering with others, I have created separate Jar files for the main packages in my application. So;
    com.me.pack1 is in Pack1.jar
    com.me.pack2 is in Pack2.jar
    An ant build takes care of building and packaging these up. The Jar files have the correct directory structure i.e.;
    jar $ $JAVA_HOME/bin/jar tf /users/jmcparla/jar/Pack1.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/me/
    com/me/pack1/
    com/me/pack1/MainClass.class
    jar $ $JAVA_HOME/bin/jar tf /users/jmcparla/jar/Pack2.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/me/
    com/me/pack2/
    com/me/pack2/OtherClass.classHowever when I run it;
    jar $ $JAVA_HOME/bin/java -cp /users/jmcparla/jar/Pack2.jar -jar /users/jmcparla/jar/Pack1.jar
    Entered main
    Created MainClass instance
    Exception in thread "main" java.lang.NoClassDefFoundError: com/me/pack2/OtherClass
            at com.me.pack1.MainClass.main(MainClass.java:13)The classes are;
    MainClass.java
    package com.me.pack1;
    import com.me.pack2.OtherClass;
    public class MainClass
        public static void main(String[] args)
            System.out.println("Entered main");
            new MainClass();
            System.out.println("Created MainClass instance");
            new OtherClass();
            System.out.println("Created OtherClass instance");
    }OtherClass.java
    package com.me.pack2;
    public class OtherClass
    }and the build file is;
    build.xml
    <project name="JarProblem" default="buildJars" basedir=".">
      <property name="classdir" value="classes"/>
      <target name="compile" depends="clean" description="compile the code">
          <mkdir dir="${classdir}"/>
          <javac debug="on" debuglevel="vars,lines,source" srcdir="."
                 destdir="${classdir}" encoding="ISO-8859-1">
          </javac>
      </target>
      <target name="buildJars" depends="compile" description="build the jar files">
        <antcall target="buildPack2"/>
        <antcall target="buildPack1"/>
      </target>
      <target name="buildPack2" description="build the Pack2 jar">
        <tstamp>
          <format property="time" pattern="hh:mm aa dd/MM/yyyy"/>
        </tstamp>
        <jar destfile="Pack2.jar" update="false">
          <fileset dir="${classdir}">
            <!-- Only include the package we're building -->
            <include name="com/me/pack2/*"/>
          </fileset>
          <manifest>
            <attribute name="Built" value="${time}"/>
          </manifest>
        </jar>
      </target>
       <target name="buildPack1" description="build the Pack1 jar">
        <tstamp>
          <format property="time" pattern="hh:mm aa dd/MM/yyyy"/>
        </tstamp>
        <jar destfile="Pack1.jar" update="false">
          <fileset dir="${classdir}">
            <!-- Only include the package we're building -->
            <include name="com/me/pack1/*"/>
          </fileset>
          <manifest>
            <attribute name="Main-Class" value="com.me.pack1.MainClass"/>
            <attribute name="Built" value="${time}"/>
          </manifest>
        </jar>
      </target>
      <target name="clean" description="clean up the compiled source files">
        <delete verbose="false" failonerror="false">
          <fileset dir="${classdir}"/>
        </delete>
      </target>
    </project>The build completes with no problems. So why can't the java command see OtherClass?

    johnmcparlald wrote:
    However when I run it;
    jar $ $JAVA_HOME/bin/java -cp /users/jmcparla/jar/Pack2.jar -jar /users/jmcparla/jar/Pack1.jar
    Entered main
    Created MainClass instance
    Exception in thread "main" java.lang.NoClassDefFoundError: com/me/pack2/OtherClass
    at com.me.pack1.MainClass.main(MainClass.java:13)
    I can't help you with ant but I can tell you that the command you entered looks wrong. If you use the -jar option with the java command, the only classpath that is used is the one specified by the Class-Path entry in the manifest - other classpaths are ignored.
    So you either need to leave off the -jar, include the Pack1.jar file and specify the main class, or include the Class-Path: Pack2.jar entry in the manifest. (At least, it looks to me like there is no Class-Path in the manifest.)

  • Importing class from default package of a JAR

    I want to create objects of a class contained in a JAR. The JAR has many classes in numerous packages, however the class that I want to use is in the default package. I'm using eclipse and have added the JAR to the build path, but eclipse complains that the class name cannot be resolved. Is there some way to specify an import statement to look in the default package of a particular JAR? Any advice is appreciated.

    jg2009 wrote:
    I was under the impression that classes without a defined package were technically considered to be part of the so-called default package. But, in answer to your question, yes this class does not appear to part of any package.
    Just to provide so additional information, the class that I want to instantiate is an Applet, so it is designed to be called from an html object tag, and have access to all of the other classes in its JAR. There is a system that provides access to underlying data via the following components: html form <-> javascript <-> applet <-> serverlets <-> data
    I want to automate certain data operations, but the only way to access the underlying data is via the applet. Am I out of luck, or is there some way that I can instantiate the applet?All jverd said is right, assuming it is your code and you can change it: basically move everything to a package. But I think your problem is that the jar is a 3rd party jar and you cannot change it. If this is the case, you can use the 'default package' (the terminology is correct) by having your own class(es) in the default package or by using reflection (last time I tried reflection would work). Both are rather bad solutions, but if you really, really want...
    Note: Java actively discourages the use of the 'default package' and more so recently, this is why I am not even sure that reflection would still work.

Maybe you are looking for