Compiling file with servlet.jar

Hi,
I can compile my file under the arm/pdm package fine by using this command:
javac -classpath .;.. pdm\FileName.java
but now i wrote a servlet which imports the javax.servlet directory.
So in order for the class to compile i have to give it the path of the servlet.jar file which is in this directory: c:/jdk1.3.1_07/lib/servlet.jar
The problem am having is that i can't give both the classpaths at one time in order to compile my servlet which also uses classes in the pdm directory and also from a different directory under arm.
Please help
Thanks

Perhaps
javac -classpath .;..;c:\jdk1.3.1_07\lib\servlet.jar pdm\FileName.java

Similar Messages

  • Some problems with servlet.jar and tomcat 4.1.27

    Hello everybody,
    I used to work with tomcat 3.3.1 and i've decided to use tomcat 4.1.27 now. The manual explains that we have to change de version of servlet.jar, it's done with servlet-2.3.jar but on tomcat starting i have this message:
    jar not loaded. See servlet spec [...]. Offending class: javax/servlet/Servlet.class
    what can i do, i've red all de documentation and i think all versions a OK??
    thanks per advance
    antoine

    I am running Tomcat 4.1.18, so your configuration may be slightly different. I found the Servlet.class file you are missing residing in the Tomcat/common/lib directory in the Servlet.jar file. Check your path and also make sure your Servlet.jar file contains the missing class.

  • Problem Compiling Projects with Servlet & Custom Taglibs

    There was a bug in Jdeveloper 3 that if you compiled JSP's that used Custom Tags Jdeveloper validated your web.xml file - very annoying (if anyone knows a workaround plese let me know). There is a workaround in JDeveloper 9 detailed in the release notes http://otn.oracle.com/products/jdev/htdocs/readme_902.html. Has this been fixed in 10g. Incidently I loaded the Oracle Developer Suite 10g documentaion cd dated April 04 and JDevloper was described as 9i - is this the latest version ?

    Perhaps
    javac -classpath .;..;c:\jdk1.3.1_07\lib\servlet.jar pdm\FileName.java

  • Opening files with servlet

    Okay... I'm new to using servlets. Not so much to jsp, just to using servlets. I have one process on our site that is using servlets and I'm trying to mimic how that is using em but am having no luck.
    I am trying to open files with a servlet. I have the class built and compiled, but mainly pulled it from Java World. I evenually will need to pass the servlet the filename and path I want open but in this example it has the file set. My problem is I want to send users to a jsp file where I check user authentication and call the servlet to open the doc, but I don't know how to call the servelet or what to send it. If someone could maybe walk me through this.
    Here's my servlet:
    package cmxx.fileServe;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class fileServe extends HttpServlet {
    final static String CONTENT_TYPE_DOC = "application/msword";
    final static String CONTENT_TYPE_HTML = "text/html";
    final static String document = "/docs/form_41.doc";
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    doGet(request, response);
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    PrintWriter out;
    out = response.getWriter();
    HttpSession websession = request.getSession(true);
    response.reset();
    response.setDateHeader ("Expires", 0);
    response.setDateHeader("max-age", 0);
    try {
         response.setContentType(CONTENT_TYPE_DOC);
    FileInputStream fileInputStream = new FileInputStream(document);
    ServletOutputStream servletOutputStream = response.getOutputStream();
    int bytesRead = 0;
    byte byteArray[] = new byte[4096];
    while((bytesRead = fileInputStream.read(byteArray)) != -1) {
         servletOutputStream.write(byteArray, 0, bytesRead);
    servletOutputStream.flush();
    servletOutputStream.close();
    fileInputStream.close();
    } catch(Exception ex) {
         throw new ServletException(ex.getMessage());
    } /* end doget */
    } /* end class */

    I'm trying a new servlet. But am getting a few compile errors. Can someone help?
    Here are my Errors:
    43 cannot resolve symbol
    symbol : class URL
    location: class cmis.fileServe.fileServe2
    URL url = new URL(fileURL);
    ^
    43 cannot resolve symbol
    symbol : class URL
    location: class cmis.fileServe.fileServe2
    URL url = new URL(fileURL);
    ^
    57 cannot resolve symbol
    symbol : class MalformedURLException
    location: class cmis.fileServe.fileServe2
    } catch(final MalformedURLException e) { 
    ^
    Code:
    package cmis.fileServe;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class fileServe2 extends HttpServlet {
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    ServletOutputStream out = res.getOutputStream();
    // Set the output data's mime type
    res.setContentType( "application/pdf" ); // MIME type for pdf doc
    // create an input stream from fileURL
    String fileURL = "http://www.adobe.com/aboutadobe/careeropp/pdfs/adobeapp.pdf";
    // Content-disposition header - don't open in browser and
    // set the "Save As..." filename.
    // *There is reportedly a bug in IE4.0 which  ignores this...
    res.setHeader("Content-disposition", "attachment; filename=Example.pdf" );
    // PROXY_HOST and PROXY_PORT should be your proxy host and port
    // that will let you go through the firewall without authentication.
    // Otherwise set the system properties and use URLConnection.getInputStream().
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    try {
    URL url = new URL(fileURL);
    // Use Buffered Stream for reading/writing.
    bis = new BufferedInputStream(url.openStream());
    bos = new BufferedOutputStream(out);
    byte[] buff = new byte[2048];
    int bytesRead;
    // Simple read/write loop.
    while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
    bos.write(buff, 0, bytesRead);
    } catch(final MalformedURLException e) {
    System.out.println ( "MalformedURLException." );
    throw e;
    } catch(final IOException e) {
    System.out.println ( "IOException." );
    throw e;
    } finally {
    if (bis != null)
    bis.close();
    if (bos != null)
    bos.close();
    } /* end class */

  • Can't compile client with client.jar

    I am unable to compile a static client using the standard client.jar produced by
    Weblogic. I am trying to do this in a minimal DOS environment as shown below:
    set PATH=d:\jdk1.3.1\bin
    set classpath=.;client.jar
    javac OssNodeWeblogicClient.java
    The compiler gives me the following error:
    client.jar(com/nyiso/oss/ossnode/OssNode.java):2:
    class OssNode is public, should be declared in a file named ossNode.java
    (source unavailable)
    1 error
    I was surprised to find two java files in client.jar (OssNode.java and OssNodeFactory.java).
    These files seem to confuse javac. If I remove these files from client.jar, the
    compilation completes without errors and the client runs without any problems.
    Has anyone seen this problem?

    Naresh,
    Just a quick follow-up. I used the -verbose option with
    javac and saw that when my compile failed, and I saw the same
    error message that you saw, javac was pulling the .java file
    from the jar file and trying to compile it. In the example I
    did that worked, the javac compiler was pulling the .class file
    from the jar file instead.
    Basically the javac compiler will fail trying to compile
    the .java file located in a jar file, probably because it can't
    write the .class file to the same (compressed) location. The
    reason that the javac compiler is trying to recompile the .java
    file, even though the .class file is also in the jar file, is
    that it has determined that the .java file is more up to date.
    So two questions for WebLogic:
    1) Why does WebLogic include the .java files in the jar
    file?
    2) Why doesn't the .java file match with the .class file?
    I'll let you know if/when I hear more. Rob
    "Naresh Bhatia" <[email protected]> wrote:
    >
    I am unable to compile a static client using the standard client.jar
    produced by
    Weblogic. I am trying to do this in a minimal DOS environment as shown
    below:
    set PATH=d:\jdk1.3.1\bin
    set classpath=.;client.jar
    javac OssNodeWeblogicClient.java
    The compiler gives me the following error:
    client.jar(com/nyiso/oss/ossnode/OssNode.java):2:
    class OssNode is public, should be declared in a file named ossNode.java
    (source unavailable)
    1 error
    I was surprised to find two java files in client.jar (OssNode.java and
    OssNodeFactory.java).
    These files seem to confuse javac. If I remove these files from client.jar,
    the
    compilation completes without errors and the client runs without any
    problems.
    Has anyone seen this problem?

  • Compiling files with the 'package'-statement

    Hi,
    I have a problem compiling files that uses the 'package'-statement:
    I have 2 files ClassA.java and ClassB.java. ClassA uses objects of type ClassB. When I compile ClassA.java the compiler also automatically compiles ClassB.java. No problem so far.
    But when I add "package mypackage" to ClassA.java and ClassB.java and then try to compile ClassA.java with the command "javac -d . ClassA.java" I get the compile-error "Class mypackage.ClassB not found". This would mean that I would have to compile all my files separately?
    Can anybody tell me what I am doing wrong?
    Thx,
    Jan

    I was still working on it, but I think I have it now :-)
    Let me try to summarize what I think/hope that I understand:
    I have the following files in package mypackage:
    C:\src\mypackage\ClassA.java
    C:\src\mypackage\ClassB.java
    with ClassA using ClassB.
    I want to compile them into C:\classes\mypackage\ClassA.class and C:\classes\mypackage\ClassB.class
    I change directory to C:\classes and then give the command
    >javac -d . ..\src\mypackage\ClassA.java
    This didn't work at first because my classpath wasn't set correctly. To make it work I had to add C:\src to my classpath. Which surprised me a little because I thought that the classpath was only used to find *.class files and not by javac to find *.java files?
    If anybody has something to add to this, please feel free to do so.
    Jan

  • Error in compiling: file javax\servlet\jsp\PageContext.class not found

    Hi,
    i'm getting an error when I'm trying to compile an java file. The error is as follows:
    cannot access javax.servlet.jsp.PageContext
    file javax\servlet\jsp\PageContext.class not found
    Isn't the javax package included in jdk? I've installed jdk 1.3.1_03 and j2re1.4.0_02. Shouldn't this PageContext.class be automatically loaded when i've installed jdk?
    I'm getting desperated! I've tried almost everything: i've changed the classpath, moved the directory of the java file I'm trying to compile over and over but i'm getting no success!
    Any help is very welcome!
    Thankx,
    Nuno.

    hmmm... i had a look and it seems that what you are trying to "import" is actually in a package... instead of import try:
    package javax.servlet.jsp;you may need to go download this "package" and complile it in the directory you are working in.
    my advice: try the above statement (which does compile for me), if it doesn't work, you will need to find the source code for this package and compile it just like you do any other source code.
    hope this helps.

  • Compiling files with nested directory structure

    I'm getting "resolve symbol" errors when I try to compile source files which
    are in the child directory whose dependent on files from it's parent
    directory. Here's my current directory structure:
    src
    -->a
    ---->b
    ------>util
    What I'm trying to do is compile files which are in the 'util' directory.
    Some of these files use some of the classes in the 'b' directory. My
    compile statement is the following:
    java -d class -classpath src src\a\b\util\aFile.java
    Files in the 'util' directory has a import a.b.* statement on top, but I
    don't think that's the problem, let alone necessary.
    Any assistance would be appreciated.

    Files in the 'util' directory has a import a.b.*
    statement on top, but I
    don't think that's the problem, let alone necessary.You must import classes that you use if the classes are not in the same package. The classes in src\a\b should have a package statement as the first line of source code and I am guessing it should be "package a.b;" Likewise, the classes in src\a\b\util should have a "package a.b.util" line. It's hard to guess what you have in mind. If you have the package statements, then the classes in a.b.util can import a.b.whatever. This will work.

  • Save byte array (image) to file with servlet

    Good day.
    I should must to save a png image to file.
    I have a byte array of the image.
    This work is in a servlet.
    How can I do it?
    Best regards.
    Stefano Errani

    Good day.
    I have a byte[] and then I have used
    FileOutputStream fos = new FileOutputStream(getServletContext().getRealPath("/public_html/mcfoto/foto1.png"));
    fos.write(bt, 0, bt.length); // byte[] bt
    fos.close();
    This on my web server that has public_html as root web directory.
    The server is in multi domain.
    In this mode I have an error.
    Then I have tryied to use
    FileOutputStream fos = new FileOutputStream("http://www.stefanoerrani.it/mcfoto/foto1.png");
    and
    FileOutputStream fos = new FileOutputStream(getServletContext().getRealPath("http://www.stefanoerrani.it/mcfoto/foto1.png"));
    In both ways I have obtained an error.
    At last I have tryied in my localhost (local machine) using
    FileOutputStream fos = new FileOutputStream(getServletContext().getRealPath("/mcfoto/foto1.png"));
    All run correclty.
    The Application Server is Tomcat with Apache HTTP Server.
    The first server (of www.stefanoerrani.it) has Linux as OS.
    My local server has Windows as OS.
    I should want, if it's possible, an help.
    Best regards.
    Stefano Errani

  • Generating JNLP file with servlet?

    Hi all,
    I want to pass in paramters from a hyperlink into a webstart application. Now I know this can be done with webstart 1.5, but using this is not an option for us. What I would like to do is to create a servlet that generates a JNLP file from any parameters passed into it on the hyperlink.
    Has anybody done this? Is this possible? would there be any problems with this?
    thanks,
    J

    That's running fine with us. That has been the way for us to transmit authentication information to pass inside the JNLP world.
    Be very careful with your output, there's no validation at the client and errors created by wrong JNLPs can be really unpredictable. Do use the DTD to at build time to check the output!
    The JNLP file will be downloaded every-time if you output correct headers...
    paul

  • Itnitialization files with servlets

    I just started reading Core Servlets and JSP. I must have missed something. The author explains the use of init files, but what is the purpose of giving values to variables in a seperate file? In the example in the book he sets a string and an integer in an init file. I can understand that you might want that if you have several servlets that use those variables as if they were global variables. I guess in that case I would understand, but can someone tell me why they are used instead of just declairing the variables inside the sevlet itself?
    Thanks,
    Keith

    If yu declare a variable and initiliaze it with a value (hard coding) in the servlet, would you be abe to change its value without re-copmpiling the servet ?
    It all about genericity and maintainability.
    All such enivronmental information that can potentially change(for example development time versus deployment time) is better put into some kind of properties/configuration/init file.

  • Xcode Mac OS X 10.7.5 doesn't compile file with math header

    Hello!
    I've written a simple program (just at the beginning of my programming path). A few people have tested it on their machines, and it works: their Xcode compiles the program. My Xcode does not.
    Here is the program.
    #include <math.h>
    #include <stdio.h>
    int main (void)
       float x = 2.55, y1, y2 ;
       int   i = 3, z = 2 ;
             y1 = pow( x, i ) ;
             y2 = pow( x, z ) ;
       float result ;
       result = 3 * y1 - 5 * y2 + 6 ;
       printf ("If x equals %f, then the given polynomial equals %f\n", x, result) ;
       return 0 ;
    Here is what I get after trying to compile:
    alla [11:41 AM]
    95-28-37-123:~ Alla$ gcc Prog3task6add.c -o Prog3task6add
    Undefined symbols for architecture x86_64:
    "_main", referenced from:
         start in crt1.10.6.o
    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    Besides this program, programs with simple #include <stdio.h> header work perfectly.
    I use Mac OS X 10.7.5 Scode 4.6.3
    Thank you very much!

    Hello!
    I have tried to use the flag in the program below. Although the program has no reference to math.h library, it returns the same error message.
    /* Program to calculate the average of a set of grades and count the nuber of failing test grades */
    #include <stdio.h>
    int main (void)
        int number_of_grades, i, grade;
        int grade_total = 0, failure_count = 0 ;
        float average ;
        printf ("How many grades will you be entering? ") ;
        scanf ("%i", &number_of_grades) ;
        for ( i = 1; i <= number_of_grades; ++i )
            printf ("Enter grade #%i: ", i) ;
            scant ("%i", &grade) ;
            grade_total += grade ;
            if ( grade < 65 ) ;
            ++failure_count ;
        average = (float) grade_total / number_of_grades ;
        printf ("\nGrade average = %.2f\n", average) ; // Precision to two decimal points
        printf ("Number of failures = %i\n", failure_count) ;
        return 0 ;
    Error message:
    Undefined symbols for architecture x86_64:
      "_scant", referenced from:
          _main in cchfawYD.o
    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    I would be grateful for ideas on how to solve this. Can it be due to the older version of git?
    Thank you so much!

  • How to load compile file

    I have been using third party software called Gauss in my java application. I compile Gauss file using Gauss compiler and then store compiled file ("xyz.e.gcg") in particular directory. After loading all Gauss related DLL into memory using System.loadLibrary(), I can execute this compiled file by passing relative and/or full path to Gauss native API (i.e. executeCompiledFile(String string)) which in turn load file into memory. This stand alone java program works fine. But with JAWS, since i don't know full/relative path of compiled file, i am not able to load compile file ("xyz.e.gcg") from jar file into memory. I am able to load all other resource files(i.e. *.gif, *.jpeg) and all required DLL from corresponding jar files into memory.
    How can i extract full/relative path of compiled file from jar file and pass it on to third party API.
    I used class loader to extract path of compiled file from jar file but that path doesn't work. I get following path for compiled file from class loader.
    file:/C:/Lukens/ToolKit/Toolkit%20for%20JAWS/resources.jar!/resources/toolkit/sva/proc_estimations_final.e.gcg
    Thanks
    Prashant

    You could read the compiled file from the jar (using java), and write a copy to a temporary file and then execute the temporary file copy.
    See also http://forum.java.sun.com/thread.jsp?forum=38&thread=443358

  • Help needed. Problem with servlet.

    Hello ppl. Ok. I've never really needed to implement servlets in my projects before but I experimented by writing a simple helloworld servlet. It compiled successfully and I tested it in the examples servlet dir and it worked. To test it in the ROOT dir, I placed the servlet in the ROOT/WEB-INF/classes folder and edited the web.xml file with:
    <servlet>
              <servlet-name>HelloWorldExample</servlet-name>
              <servlet-class>HelloWorldExample</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>HelloWorldExample</servlet-name>
              <url-pattern>servlet/*</url-pattern>
         </servlet-mapping>
    When I try and execute the servlet by using this URL: localhost:8080/servlet/helloworld I get an internal server error and the server crashes. I removed the entry from the web.xml file and Tomcat started up again. What went wrong? Can someone enlighten me in how to get my test servlet working becuase i may use them in the future. Thanks.

    Nope, Still didnt work. As soon as I put in:
    <servlet>
         <servlet-name>HelloWorldExample</servlet-name>
         <servlet-class>HelloWorldExample</servlet-class>
         </servlet>
         <servlet-mapping>
         <servlet-name>HelloWorldExample</servlet-name>
         <url-pattern>servlet/HelloWorldExample</url-pattern>
         </servlet-mapping>
    Tomcat went offline!
    I have another entry which is:
    <servlet>
              <servlet-name>org.apache.jsp.index_jsp</servlet-name>
              <servlet-class>org.apache.jsp.index_jsp</servlet-clas
    >
         </servlet>
         <servlet-mapping>
              <servlet-name>org.apache.jsp.index_jsp</servlet-name>
              <url-pattern>/index.jsp</url-pattern>
         </servlet-mapping>
    Do you think they may be conflicting? Thanks.Tomcat going offline is quite weird. However,
    <url-pattern>/index.jsp</url-pattern>
    this is perfectly valid. Lemme ask you this: did u come up with this stuff on your own or was it generated for you by the container? It looks like it was generated upon compilation of the jsp. If that is the case it should cause any conflicts. However now if you want to invoke the servlet/jsp you must use a URL like:
    http://localhost:<PORT_NO>/index.jsp
    Cheers

  • Compiling a jar or zip file with Ant

    Hi,
    I am using Java 1.4.2 and Ant 1.6.1
    I am trying to use the javac task to compile a jar file and a zip file directly (i.e. they contain compressed .java files) instead of uncompressing them first and then compiling them. Is it supported in Ant?
    i.e.
    <target name="compileinit">
    <mkdir dir="${compile.outdir}"/>
    <!--Compile Java source files in a jar file-->
    <javac destdir="${compile.outdir}" debug="on">
    <classpath refid="classpath"/>
    <src refid="srcpath"/>
    <include name="jarfile.jar"/>
    <include name="zipfile.zip"/>
    </javac>
    </target>
    Thanks!

    It's not clear what you are asking. Maybe this will help
    http://www.cfdev.com/code_samples/code.cfm/CodeID/83/Java/Simple_Ant_build_xml_Build_Task

Maybe you are looking for