troubleshooting Question

Trouble Creating jarfile

Avatar of Mark
Mark asked on
JavaJSP
30 Comments1 Solution376 ViewsLast Modified:
I've had little success with creating my own jarfiles. Here's my latest attempt. I have the java file hprsPurchase.java:

import java.util.Date;
import java.text.SimpleDateFormat;

class hprsPurchase {

public static Date snagFinalPaymentDate()
{
    return new Date();
}

} // endclass


I do the following:

$ javac hprsPurchase.java
$ jar cf hprsPurchase.jar hprsPurchase.class
$ sudo cp hprsPurchase.jar $CATALINA_HOME/common/lib

I add $CATALINA_HOME/common/lib/hprsPurchase.jar to my CLASSPATH and restart tomcat

I add <%@ page import="hprsPurchase.*" %> to my jsp file. Without referencing the snagFinalPaymentDate() function the jsp file "compiles" at this point. (If I leave off the ".*" I get: The import hprsPurchase cannot be resolved")

When I do reference the function:

Date now = new hprsPurchase.snagFinalPaymentDate();

I get the error:

An error occurred at line: 192 in the jsp file: /finalPaymentReport.jsp
hprsPurchase cannot be resolved to a type;

I also tried:

Date now = new Date();
now = hprsPurchase.snagFinalPaymentDate();

and got:

hprsPurchase cannot be resolved

What am I doing wrong?

Linux kernel 2.6.37.6
javac version: 1.7.0_02
tomcat version: 6.0.14
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 30 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 30 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros