How to compile java file in Tomcat ?

Hi all,
I have a java file named Ch1Servlet.java under project1/src directory
there is classes directory project1/classes and web.xml under src directory
project1/src directory.
Now to compile i have to give %javac -classpath /your path/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java
What is this your path ? Tomcat 5.0 is installed in C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib with servlet-api.jar
Please help me out.
Best Regards
Taton
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Ch1Servlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("<html>"+"<body>"+"<h1 align = center>HF\'s Chapter 1 Servlet</h1>"+"<br>"+today+"</body>"+"</html>");
}

understand 1 thing..ur tomcat is not a compiler as u
think..its a poor web server only..
Its not mandatory that u need to put the source files
in tomcat folder.u can put ur java files where ever u
want..put servlet.jar in ur classpath.
then start compiling ur java files..once u are done
with compiling copy the class files alone to ur
web-inf classes folder.
thats it!!!
regards
shanuservlets12.jar

Similar Messages

  • How to compile java files in a bunch of drectories?

    I have a bunch of java files in a bunch of different directories. How can I compile them all at once? Please note I also do not know how to get javac to work outside the java directory.

    put it another way, what I am trying to do is to compile David Brackeen's ch 18 code from his book. The java sourse files can be downloaded here:
    http://www.brackeen.com/javagamebook/
    my question is that how would I complie all of these file so that I can get the program in ch18src\src\com\brackeen\javagamebook\test\ to run?

  • Compiling .java file on tomcat 4.1

    i wana know where to store the .java file on the tomcat directory for tomcat to compile it?
    and then after putting it in the appropriate place is this command gona compile it: javac -cp "c:program files\apache group\tomcat 4.1\common\lib\jasper-compiler.jar" yourservlet.java
    if this is not the correct command then wat is the easiest way to compile the servlet?
    thank you in advance.

    Hi,
    I've never heard about .java auto compilation in Tomcat, but anyway, that wouldn't be a goddo aproach, don't you think so? Why don't you publish your application in a single .war file? You could even sent you JSPs compiles, avoiding performance problems...

  • How to compile Java files using Ant in Eclipse

    Hi All ,
    I would like to compile all Java files using Ant in Eclipse.Since am very new to Ant and Eclipse can someone help me to create a build.xml file and let me know how to compile all the java files.
    For ex , I have placed my java files inside the path C:\HEC\Terab.Initially the Terab folder holds 7 jar files which i had decompiled using JD compiler and placed the unzipped 7 folders (which contains the java files ).Now i have imported the HEC project into Eclipse using New ->Project ->Java Project.after importig it throwed me an error saying missing jar files.again i copied the jar files and placed inside Terab folder with other 7 folder.
    Now How i can compile the java files and convert in to class files.Then after compiling the files i will again need to jar all the 7 folder.
    Please tell me the steps i need to follow.How to write an build.xml file ? where i should keep it ? only one build.xml file is enough or should i write 7 build.xml file for each folder ? Please help me out...
    Thanks & Regards
    Kar1983

    put it another way, what I am trying to do is to compile David Brackeen's ch 18 code from his book. The java sourse files can be downloaded here:
    http://www.brackeen.com/javagamebook/
    my question is that how would I complie all of these file so that I can get the program in ch18src\src\com\brackeen\javagamebook\test\ to run?

  • How to compile .java files in windows server

    Hi All,
    I want to compile my CO.java file in server directly how can i do that my server is windows server
    If it is Linux i can login through putty and go to java top and then file location then i use to do javac filename.java then i use to get filename.class but now same thing i did in windows server which is not working please sugget how to do its bit urgent.

    Why do you want to compile it on the server and not in jdeveloper? You should be able to issue the javac command from the prompt. Your unix account must have permissions to that command though.
    For more info on the javac command:
    http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javac.html
    Kristofer Cruz

  • Compiling java file in 11i

    I need to compile java file in CRM 11i .

    1003984 wrote:
    I need to compile java file in CRM 11i .Please see (HOW TO COMPILE JAVA FILES IN CRM APPLICATIONS [ID 468434.1]).
    Thanks,
    Hussein

  • How to check the JDK version of a compiled java file

    can anybody tell me how to check the JDK version of a compiled java file ?
    Edited by: gbhatia8 on Sep 9, 2010 7:04 AM

    The major/minor version of the class file is the way to go.
    Also, it's not necessary to write a separate program to get to those. javap prints them out when being passed the -v flag.
    Note, however that "JDK version" is not a correct term, as I can create 1.4-compatible class files with a Java 6 JDK (by passing the -target flag to javac). Those won't look any different than .class files written with a 1.4 JDK.

  • How does javac compile .java files?

    I dont know exactly what classpath javac uses to compile java files. i have set classpath to only tools.jar . and it compiles fine. i thought all standard java class files are present in tools.jar. But... when i opened tools.jar i didnt find most of the class files i expected to see there. In fact there was no java.lang, java.io ... so on packages in it. then how is that compiler compiled ? Of course i found rt.jar under jre/lib, which contained all the mentioned packages...but then i didnt give it in the classpath.
    Any body pls clear my doubts.

    Check out the doc "how classes are found" in the tool
    docs, it will explain how classes are found in
    detail.
    tool docs:
    http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html
    I read the docs and understood that javac.exe loads dt.jar before it could compile .java files. but then what is the use of giving tools.jar in classpath.. i ve seen javac giving problems without it.

  • Error while compiling java file

    Hi, im newby in java,
    i was trying to compile java files, and after that i will use it in JSP as javabean.
    I have 2 files already, the first file is a connection code, and its compiled successfully, it looks like this
    i named this as ConnectionBean.java
    package my_package;
    import java.sql.*;
    public class ConnectionBean {
         private Connection con;
         private static final String driver = "org.postgresql.Driver";
         private static final String url = "jdbc:postgresql://localhost:5432/PSQLDS";
         private static final String username = "postgres";
         private static final String password = "mypassword";
         public ConnectionBean() {
         public Connection logOn() {
              try {
                   Class.forName(driver); con = DriverManager.getConnection(url, username, password); }
              catch(ClassNotFoundException e) {
                   System.err.println("ConnectionBean: driver unavailable..."); con = null; }
              catch (SQLException e) {
                   System.err.println("ConnectionBean: driver not loaded..."); con = null; }
              return con;
         public void logOff() {
              try {
                   con.close(); }
              catch (Exception e) {
                   e.printStackTrace(); }
    as you can see above im using "package", and yes i have manage to put all my java files within the correct path (ROOT\WEB-INF\classes\my_package)
    And also, i have test this class as javabean on JSP file and it works.
    There for i continue to create the second java file, as a purpose to create a back engine for JSP. I use the same package as ConnectionBean.java, it looks like this
    i named this as ListPageEngine.java
    package my_package;
    import java.beans.*;
    import java.sql.*;
    public class ListPageEngine {
         public static void main(String[] args) {
              ConnectionBean conBean = new ConnectionBean();}
    on compiling process using command "javac ListPageEngine.java", i get this error message
    ListPageEngine.java:11: cannot find symbol
    symbol : class ConnectionBean
    location: class my_package.ListPageEngine
    ConnectionBean conBean = new ConnectionBean();}
    ^
    ListPageEngine.java:11: cannot find symbol
    symbol : class ConnectionBean
    location: class my_package.ListPageEngine
    ConnectionBean conBean = new ConnectionBean();}
    ^
    2 errors
    I think, i am pretty much sure that all my configuration (wheater its Apache TomCat, Environment Variable or PostgreSQL server) was good, as a prove, i was able to use ConnectionBean.class in my JSP file.
    I susspect the problem is related with "package", seems i cannot use ConnectionBean class within ListPageEngine class when i use package.
    For another information, i didn't install such thing as J2EE, i only install JDK 1.5, i also guess this might be the cause.
    Right now im all stuck, i try to find thread which might be related with my problem but i failed to find it, most of them get the same answer by UncleSAM which are
    Try the following forum (about JSP technology)
    http://forum.java.sun.com/forum.jspa?forumID=45
    JavaBeans spec contains nothing about JSP, but JSP spec describes using of beans.
    i hope my question is clear so anyone who might have experience or clue with this problem might be able to help me.
    Thanks before

    finally folks, i found answer to my own problem hehehehe..
    the problem is on the compiling command (javac ... my_file.java), i found that i need to add some parameter on the command to make it works.
    This problem solved.

  • Java6: How to compile java using JavaCompiler class

    Hi all,
    Using JavaCompiler, we can run the java program thru programmaticaly using run() method.
    Could anyone please tell me how to compile a java program using JavaCompailer class? Or calling run() itself will compile java file?
    Thanks
    Shagil

    import spoon.support.input.SpoonInputStream;
    import com.sun.tools.javac.code.Symbol.ClassSymbol;
    import com.sun.tools.javac.comp.Attr;
    import com.sun.tools.javac.comp.AttrContext;
    import com.sun.tools.javac.comp.Enter;
    import com.sun.tools.javac.comp.Env;
    import com.sun.tools.javac.comp.Todo;
    import com.sun.tools.javac.tree.Tree;
    import com.sun.tools.javac.tree.Tree.ClassDef;
    import com.sun.tools.javac.tree.Tree.TopLevel;
    import com.sun.tools.javac.util.Abort;
    import com.sun.tools.javac.util.Context;
    import com.sun.tools.javac.util.List;
    import com.sun.tools.javac.util.ListBuffer;
    import com.sun.tools.javac.util.Log;
    import com.sun.tools.javac.util.Name;
    * The Spoon compiler (uses javac).
    public class SpoonCompiler extends com.sun.tools.javac.main.JavaCompiler {
         Attr attr;
         Enter enter;
         boolean hasBeenUsed = false;
         Log log;
         Todo todo;
         public SpoonCompiler(Context arg0) {
              super(arg0);
              enter = Enter.instance(arg0);
              todo = Todo.instance(arg0);
              log = Log.instance(arg0);
              attr = Attr.instance(arg0);
              sourceOutput=true;
          * Main method: compile a list of files, return all compiled classes
          * @param filenames
          *            The names of all files to be compiled.
         @SuppressWarnings("unused")
         public List<Tree> parseAndAttribute(List<SpoonInputStream> filenames)
                   throws Throwable {
              // as a JavaCompiler can only be used once, throw an exception if
              // it has been used before.
              assert !hasBeenUsed : "attempt to reuse JavaCompiler";
              hasBeenUsed = true;
              long msec = System.currentTimeMillis();
              ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
              try {
                   // parse all files
                   ListBuffer<Tree> trees = new ListBuffer<Tree>();
                   for (List<SpoonInputStream> l = filenames; l.nonEmpty(); l = l.tail) {
                        trees.append(parse(l.head.getFileName(),l.head.getStream()));
                   // enter symbols for all files
                   List<Tree> roots = trees.toList();
                   if (errorCount() == 0)
                        enter.main(roots);
                   // If generating source, remember the classes declared in
                   // the original compilation units listed on the command line.
                   List<ClassDef> rootClasses = null;
                   if (sourceOutput || stubOutput) {
                        ListBuffer<ClassDef> cdefs = new ListBuffer<ClassDef>();
                        for (List<Tree> l = roots; l.nonEmpty(); l = l.tail) {
                             for (List<Tree> defs = ((TopLevel) l.head).defs; defs
                                       .nonEmpty(); defs = defs.tail) {
                                  if (defs.head instanceof ClassDef)
                                       cdefs.append((ClassDef) defs.head);
                        rootClasses = cdefs.toList();
                   while (todo.nonEmpty()) {
                        Env<AttrContext> env = todo.next();
                        // save tree prior to rewriting
                        Tree untranslated = env.tree;
                        // attribution phase
                        if (verbose)
                             printVerbose("checking.attribution", env.enclClass.sym);
                        Name prev = log.useSource(env.enclClass.sym.sourcefile);
                        attr.attribClass(env.tree.pos, env.enclClass.sym);
                   return trees.toList();
              } catch (Abort ex) {
                   ex.printStackTrace();
              if (verbose)
                   printVerbose("total", Long.toString(System.currentTimeMillis()
                             - msec));
              int errCount = errorCount();
              if (errCount == 1)
                   printerCount("error", errCount);
              else
                   printerCount("error.plural", errCount);
              if (log.nwarnings == 1)
                   printerCount("warn", log.nwarnings);
              else
                   printerCount("warn.plural", log.nwarnings);
              return null;
         private void printerCount(String str, int val) {
              System.err.println(str + " - " + val);
         private void printVerbose(String arg0, Object obj) {
              System.out.println(arg0 + " - " + obj.toString());
    --- NEW FILE: CtBuilder.java ---
    package spoon.support.builder;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.List;
    import java.util.Map;
    import java.util.Set;
    import java.util.Stack;
    import java.util.TreeSet;
    import spoon.query.Query;
    import spoon.query.TypeFilter;
    import spoon.reflect.CtFactory;
    import spoon.reflect.code.BinaryOperatorKind;
    import spoon.reflect.code.CtAbstractInvocation;
    import spoon.reflect.code.CtArrayAccess;
    import spoon.reflect.code.CtAssert;
    import spoon.reflect.code.CtAssignment;
    import spoon.reflect.code.CtBinaryOperator;
    [...1760 lines suppressed...]
                var.setSimpleName(tree.sym.name.toString());
                var.setModifiers(getModifiers(tree.mods.flags));
                enter(var, tree);
                scan(tree.init);
                exit(var, tree);
        @Override
        public void visitWhileLoop(WhileLoop tree) {
            CtWhile whileLoop = new CtWhileImpl();
            enter(whileLoop, tree);
            builderContext.loopParameter = 1;
            scan(tree.cond);
            builderContext.loopParameter = 0;
            scan(tree.body);
            exit(whileLoop, tree);
    }

  • How to compile java to exe by JDeveloper?

    How to compile java to exe by JDeveloper?

    You used to be able to use exegen to generate stand alone executables for Windows, but this no longer works in later versions of Windows. It works for Windows 98 and NT. For example
    exegen/main:schedserv /out:sched.exe schedserv.class scheduler.class
    will generate the executable sched.exe from the two class files.
    Probably MicroSoft decided to make life a bit harder for Java users.

  • How to run .java file in windows ?

    How to run .java file in windows without installing any program? Thx!

    First, U must make sure that there is JDK on your computer
    Then, set the envionment variables which the os can find your compiler and interpreter: javac java
    after those, you must complie your .java file to .class file, then you can excute it by java, for example " java helloworld"

  • Running a compiled java file

    Question: if a pc doesn't have the jre, how can it launch a compiled java file? For example, i create a program that calculates the expenses of a factory, i create the gui and i compile the file. Then i distribute my program. If a factory doesn't have jre, i suppose it can't launch the program...how can i do? can i create an exe file from java one?

    If the machine has a browser, it probably has a jre, but that is beside the point. No it cannot run without a jre. If there is not one, it must be installed.

  • Convert  strange  characters  to  compilance java file

    Hi guys
    I need help!
    How I can translate these strange characters
    into an compilance java file
    are these a memory locations ,machine language , or
    in which language they are written?
    thanks in advance.
    �� - y ��� � ()I ()J ()Ljava/lang/String; ()V ()Z (I)Ljava/lang/String; (IC)Ljava/lang/StringBuffer; (II)Ljava/lang/String; (J)V (Ljava/lang/Object;)Z &(Ljava/lang/String;)Ljava/lang/String; ,(Ljava/lang/String;)Ljava/lang/StringBuffer; (Ljava/lang/String;)V '(Ljava/lang/String;I)Ljava/lang/String; '(Ljava/lang/String;Ljava/lang/String;)V - 0000 <init> Code DC- Illegal key J
    SourceFile [DashoPro-V1.3BETA-091199] a append b c com/diginet/digichat/common/a3 com/esial/util/c d e equals f g h insert java/io/Serializable java/lang/Exception java/lang/IllegalStateException java/lang/Long java/lang/Object java/lang/String java/lang/StringBuffer java/util/Random length      longValue      substring toString 5 4 3 1 % / & 0 2 . 6      - 9 ! " $ ' ! # ,
    +
    '      (      $      ! ! ) 8 8 7
    : D
    ; E
    < F
    ; G
    ; H
    = I
    = H
    > J
    ; D
    ; K     > L     > M     > N     > O �
    > P
    > Q
    > R
    > S
    > T
    @ U
    A E
    > V
    < W
    < X
    < Y
    B D
    = E
    = Z 1 > B C ! # $ ' ! ? 3� :Y� [N� ;Y+� \:+� ]6� 0� ^W����� _� ! b V*� e     �� *� f     �� �� =Y*� f� `� aL� =Y*� e� `� aM*+� bL*,� bM� ;Y� c+� d,� d� _� # b V*� g     �� *� h     �� �� =Y*� h� `� aL� =Y*� g� `� aM*+� bL*,� bM� ;Y� c+� d,� d� _� $      * *� g i�<*� f i�= �� '      A 5*� h i�<*� f i�=*� f{ i�>�~6 �� (      D 8*� h i�<*� g{ i�=�~>*� e
    { i�6 �� *
    B .*� kW*� lW*� m� *� n� *� o � �L� + + ? +
    C 7*� g
    ��@*� f
    ��B!�� !     �� � �� AY� p� q� ,
    > 2*� g{
    �<*� e{
    �=
    � � �� AY� p� q� 1 9 � �*� rL+� s� �++� ]d� tM++� ]d� uN-� ]� !� ;Y� c-� ]d� t� d-� d� _N,� ]� !� ;Y� c,� ]d� t� d,� d� _M� ;Y� c� d-� d� d,� d� _� *� v� � �*� v� ;Y� c+� u� d+� t� d� _N,� ]6-� ]6*� =Y,d� u� w� x� g*� =Y,dd� t� w� x� h*� =Y-d� u� w� x� e*� =Y-dd� t� w� x� f�{code}{code}
    Edited by: vanpersie on Feb 9, 2008 12:35 PM

    This data is Bytecode of a Java class. Read about Java Bytecode structure in Java Documentation at SUN Site.

  • Problem compiling java file to access web service! newbie troubles !

    I am new to web services and this is my first program...
    I am compiling java file which has import statement like:
    import org.apache.soap.util.xml.*;
    import org.apache.soap.*;
    import org.apache.soap.rpc.*;
    It says ----- package org.apache.soap.util.xml does not exist as one of errors..
    I have a folder that I named soap myself and I have activation.jar,serces.jar,mail.jar,soap.jar in it.
    I added c:\soap in my classpath and this was supposed to be the quickstart way to try an example out...
    but it gives me compilation errors... what should I do ?

    You'll need to specify each jar file in the classpath. c:\soap\xerces.jar;c:\soap\sax.jar;....

Maybe you are looking for

  • REP-0110: Unable to open file 'OCL_MASTER_REPORT'

    Job Name: OCL_RXCRCLRC_73 Job Status: Terminated with Error : BACKGROUND is deprecated. See help for more information. REP-0110: Unable to open file 'OCL_MASTER_REPORT'. REP-1070: Error while opening or saving a document. REP-0110: Unable to open fil

  • I tunes will not install on windows 7 64 bit

    I have upgrade to window 7 and I am trying to download I tunes.  I get a message that My Itunes was not modifying.  Errors while attempting the down load.  I have  no older versions of I tunes installed. Thans for your help. Jim

  • LAYOUT CHANGE IN FBL1N

    HI EXPERTS ! The transaction code for the report we generate is FBL1N - vendor ledger. we require the vendor's bank detail in this report at the header i.e. vendor bank name , account no..(change layout of report for output ) this detail can be seen

  • Method Validator based on two columns

    Hi, I have a table called FndCities with attributes city_id (pk), country_id (fk) and city_name. I want to check if a city name is unique for a certain country. For example England can have a city name called "London", but USA might have a city calle

  • What is "Other" in capacity bar?

    I am seeing that the "Other" items in the capacity bar of my iPhone (in iTunes) is taking up a bit of space. How do I know what the "Other" capacity consists of? I would like to free