Unable to run Servlet program using J2EE SDK

Hello,
i am a newbie to all this j2ee stuff and servlets even.so the problem that i have maybe a very common one and i hope that most of you may have a fix to it...
i use J2EE SDK to compile and run Servlet programs.I have a Servlet program with the class name defined as
public class MyServlet extends HttpServlet ....
the file is stored as MyServlet.java
i set the CLASSPATH variable so that the required classes for the compilation of the program can be located.
the program compiles without any glitches.
However when i run the program by saying
java MyServlet
( i dont think its any different to run servlet code is it?)
i get the message
java.lang.NoClassDefFoundException:MyServlet
Can someone suggest a remedy?
thank you
-NDK

First, I don't understand what you are trying to do. Running a servlet ?
Servlets are ran by an application server ! (Apache Tomcat ....).
Second, is your class in any package ?

Similar Messages

  • Unable to Run C Program using Xcode "Stop Executable"

    Hi All
    Have been using the Terminal to compile programs built through Xcode but now want to use Xcode itself. Everytime I press build and go it builds successfully but won't run. I found a tutorial that mentioned if you are using Xcode 3.0 (I am) you can't use build and run, for output, you have to go to run and then push console.Ok that works. I then found someone with the same issue as mine everytime you want to build and run it appears with another window saying "Stop Executable"They were told to make sure they were building the .c file in a project and not building it from a text editor and then importing. I always build new projects.
    I want to interact with the program not just see its output? so my question is can I interact with programs i.e. User can enter data or strings or, do I have to build an interface to do this through Xcode. I Also forgotten to mention I found information through the forum that said to go to First Aid through utilities and repair file permissions, this has been done but still does not work. Many thanks for your time and as you can probably tell I am new to Xcode.

    To run your command-line program in Xcode, open the debugger console by choosing Run > Console. Run your program by choosing Run > Run or Build > Build and Run. You'll have to build and run if you haven't compiled the program before. Your program will run, and you will see output in the console. You interact with the program from the console.
    If you're not able to enter input in the console, choose Run > Sync with Debugger. If doing that doesn't work, you can run your program in the Terminal application by double-clicking the program from the Finder. It's less convenient than running it in Xcode, but you'll at least be able to run the program and interact with it.

  • How to run servlet by using main?

    How can I use main to run servlet?
    I cannot put request and response object into doGet(request, response) method
    I want this because I want to run this servlet daily and I plan to put it in cron job
    Calvin

    Hi
    Perhaps you cannot run servlet without using browser. But you can make that program as an application in order to run in Dos or Unix shell.
    But still you can run servlet without using browser How?
    You can debug servlets with the same jdb commands you use to debug an applet or an application. The JavaTM Servlet Development Kit (JSDK) provides a standalone program
    called servletrunner that lets you run a servlet without a web browser. On most systems, this program simply runs the java sun.servlet.http.HttpServer command. You
    can, therefore, start a jdb session with the HttpServer class.
    A key point to remember when debugging servlets is that Java Web server and servletrunner achieve servlet loading and unloading by not including the servlets directory on
    the CLASSPATH. This means the servlets are loaded using a custom classloader and not the default system classloader.
    Running servletrunner in Debug Mode
    Running Java Web ServerTM in Debug Mode
    Running servletrunner in Debug Mode
    In this example, the servlets examples directory is included on the CLASSPATH. You can configure the CLASSPATH for debug mode as follows:
    Unix
    $ export CLASSPATH=./lib/jsdk.jar:./examples:$CLASSPATH
    Windows
    $ set CLASSPATH=lib\jsdk.jar;examples;%classpath%
    To start the servletrunner program you can either run the supplied startup script called servletrunner or just supply the servletrunner classes as a parameter to jdb. This
    example uses the parameter to servletrunner.
    $ jdb sun.servlet.http.HttpServer
    Initializing jdb...
    0xee2fa2f8:class(sun.servlet.http.HttpServer)
    > stop in SnoopServlet.doGet
    Breakpoint set in SnoopServlet.doGet
    > run
    run sun.servlet.http.HttpServer
    running ...
    main[1] servletrunner starting with settings:
    port = 8080
    backlog = 50
    max handlers = 100
    timeout = 5000
    servlet dir = ./examples
    document dir = ./examples
    servlet propfile = ./examples/servlet.properties
    To run SnoopServlet in debug mode, enter the following URL in a browser where yourmachine is the machine where you started servlet runner and 8080 is the port number
    displayed in the settings output.
    http://yourmachine:8080/servlet/SnoopServlet
    In this example jdb stops at the first line of the servlet's doGet method. The browser will wait for a response from your servlet until a timeout is reached.
    main[1] SnoopServlet: init
    Breakpoint hit: SnoopServlet.doGet (SnoopServlet:45)
    Thread-105[1]
    We can use the list command to work out where jdb has stopped in the source.
    Thread-105[1] list
    41 throws ServletException, IOException
    42 {
    43 PrintWriter out;
    44
    45 => res.setContentType("text/html");
    46 out = res.getWriter ();
    47
    48 out.println("<html>");
    49 out.println("<head>
    <title>Snoop Servlet
    </title></head>");
    Thread-105[1]
    The servlet can continue using the cont command.
    Thread-105[1] cont
    Running Java Web Server in Debug Mode
    The JSDK release does not contain classes available in the Java Web server and it also has its own special servlet configuration. If you cannot run your servlet from
    servletrunner, then the other option is to run the Java Web server in debug mode.
    To do this add the -debug flag for the first parameter after the java program. For example in the script bin/js change the JAVA line to look like the following. In releases prior
    to the Java 2 platform release, you will also need to change the program pointed to by the variable $JAVA to java_g instead of java.
    Before:
    exec $JAVA $THREADS $JITCOMPILER $COMPILER $MS $MX \
    After:
    exec $JAVA -debug $THREADS $JITCOMPILER
    $COMPILER $MS $MX \
    Here is how to remotely connect to the Java Web Server. The agent password is generated on the standard output from the Java Web Server so it can be redirected into a file
    somewhere. You can find out where by checking the Java Web Server startup scripts.
    jdb -host localhost -password <the agent password>
    The servlets are loaded by a separate classloader if they are contained in the servlets directory, which is not on the CLASSPATH used when starting the Java Web server.
    Unfortunately, when debugging remotely with jdb, you cannot control the custom classloader and request it to load the servlet, so you have to either include the servlets
    directory on the CLASSPATH for debugging or load the servlet by requesting it through a web browser and then placing a breakpoint once the servlet has run.
    In this next example, the jdc.WebServer.PasswordServlet is included on the CLASSPATH when Java Web server starts. The example sets a breakpoint to stop in the service
    method of this servlet, which is the main processing method of this servlet.
    The Java Web Server standard output produces this message, which lets you proceed with the remote jdb session:
    Agent password=3yg23k
    $ jdb -host localhost -password 3yg23k
    Initializing jdb...
    > stop in jdc.WebServer.PasswordServlet:service
    Breakpoint set in jdc.WebServer.PasswordServlet.service
    > stop
    Current breakpoints set:
    jdc.WebServer.PasswordServlet:111
    The second stop lists the current breakpoints in this session and shows the line number where the breakpoint is set. You can now call the servlet through your HTML page. In
    this example, the servlet is run as a POST operation
    <FORM METHOD="post" action="/servlet/PasswordServlet">
    <INPUT TYPE=TEXT SIZE=15 Name="user" Value="">
    <INPUT TYPE=SUBMIT Name="Submit" Value="Submit">
    </FORM>
    You get control of the Java Web Server thread when the breakpoint is reached, and you can continue debugging using the same techniques as used in the Remote Debugging
    section.
    Breakpoint hit: jdc.WebServer.PasswordServlet.service
    (PasswordServlet:111) webpageservice Handler[1] where
    [1] jdc.WebServer.PasswordServlet.service
    (PasswordServlet:111)
    [2] javax.servlet.http.HttpServlet.service
    (HttpServlet:588)
    [3] com.sun.server.ServletState.callService
    (ServletState:204)
    [4] com.sun.server.ServletManager.callServletService
    (ServletManager:940)
    [5] com.sun.server.http.InvokerServlet.service
    (InvokerServlet:101)
    A common problem when using the Java WebServer and other servlet environments is that Exceptions are thrown but are caught and handled outside the scope of your servlet.
    The catch command allows you to trap all these exceptions.
    webpageservice Handler[1] catch java.io.IOException
    webpageservice Handler[1]
    Exception: java.io.FileNotFoundException
    at com.sun.server.http.FileServlet.sendResponse(
    FileServlet.java:153)
    at com.sun.server.http.FileServlet.service(
    FileServlet.java:114)
    at com.sun.server.webserver.FileServlet.service(
    FileServlet.java:202)
    at javax.servlet.http.HttpServlet.service(
    HttpServlet.java:588)
    at com.sun.server.ServletManager.callServletService(
    ServletManager.java:936)
    at com.sun.server.webserver.HttpServiceHandler
    .handleRequest(HttpServiceHandler.java:416)
    at com.sun.server.webserver.HttpServiceHandler
    .handleRequest(HttpServiceHandler.java:246)
    at com.sun.server.HandlerThread.run(
    HandlerThread.java:154)
    This simple example was generated when the file was not found, but this technique can be used for problems with posted data. Remember to use cont to allow the web server
    to proceed. To clear this trap use the ignore command.
    webpageservice Handler[1] ignore java.io.IOException
    webpageservice Handler[1] catch
    webpageservice Handler[1]
    I hope this will help you.
    Thanks
    Bakrudeen

  • How to configure a servlet program using Eclipse?

    Hi,
    Am just learning Java and J2ee..Am not efficient..Don't laugh @ my question..
    I installed jdk 1.6, Apache tomcat 5.0 and eclipse 3.2.1 and also installed wtp plugin to work with j2ee perspective of eclipse..I did this in my PC..could U plz tell me what I need to install in addition?
    How come I write my Servlet program using Eclipse...
    Thanq
    Vani.

    This is the Sun Java System Messaging Server forum. Though this application software bears Java in it's name it has nothing to do with the programming language Java.

  • Compile and run java programs using batch file

    i am using eclipse to run my java programs.How to compile and run those programs using a batch file?

    a) just write a batch file, and add it to the project. When you want to run it, go to a command window and invoke it. (There is probably also a way to invoke it from Eclipse)
    b) if the project is complicated, take a look at ant. Eclispe knows about ant files.

  • How to run servlet program in eclipse 3.1

    i run the jsp program in eclipse 3.1
    i want to run sample servlet program in eclipse, how to create the project,where to store the class file..? where to store the web.xml file..?
    plz give explanation with HelloWorld.java program....

    Install WTP and follow the basic J2EE WebApp Tutorial from their WTP tutorials page.

  • How to compile and Run servlet Program

    Hi,
    pls help me the following doubt
    i am using Tomacat 4.1 server.
    1. Where is save Servlet program?
    2. How to set classpath?
    3. how compile and run?
    bye
    Mathi

    1. Where is save Servlet program?
    2. How to set classpath?
    3. how compile and run?
    http://www.coreservlets.com

  • Unable to run ADF Project Using with Jdev 10 and Weblogic server 9.2

    Dear All,
    I am unable to run ADF Project on Weblogic Server 9.2. I am created Sample Project with ADF Control. This was when we create jsp at that time i am selected libraries ADF. After created war file. This war i am deploying into Server. At that time i am getting error java.lang.noclassfound error.
    so please tell me how we can run these application.
    Regards,
    Suresh.V

    Hard to help you here. JDev 10 used to work with OAS 10g as application server. This does not mean that you can't use Weblogic9.2, but because it is not the default configuration you may have some problems doing this.
    One problem is that you need to install the ADF runtime libraries in the WLS 9.2 server, but there is no installer I know of. You can try to deploy the needed libraries together with your app, but you have to figure out which libraries you need.
    Next thing is that you should deploy an EAR instead of a WAR.
    Timo

  • How to & what to install to compile & run servlet programs

    Hi There,
    I want to know what software is the best suited in Java, for installation, by which i can compile and run my servlet programs.
    How to set the class path to run the servlet programs?
    to what file should my class path link?

    You can download and install Tomcat 3.2.x or 4.0 beta version.
    To run your servlet classes just copy them to your server's webapps directory to access them. You'll find all necessary information on the website.
    Here is the resource link:
    1. http://jakarta.apache.org/tomcat/
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • Running external program using java

    hi
    i am trying to run an external program using the runtime.exec() method. my problem is that the external program only runs when i press ctrl-c to exit my program. does anyone know how i can execute the external program while my program is still running without having to quit the program?should i be using threads?
    thanks

    As per the api doc exec will be executed as a seperate process
    Process exec(String command) ------Executes the specified string command in a separate process.
    Can you able to share that code what you have written ?

  • Running abap programs using the macros

    In our DP implementation we have faced several issues in the extraction of the data from the demand planning to one of the legacy system. We have written the ABAP program and would be using the read planning book bapi. I wanted to run the ABAP program using the macro could some one please let me know what is the structure of the macro builder that is used to fire the ABAP program. this is being fired from the macros as some comparison is to be done to run the macro.

    Hi,
    Some more information on macro function
    REPORT_SUBMIT()
    REPORT_SUBMIT( 'program_name' ;  <'job_name'> ; <'job_number'>; <'newmode'>) causes the specified program to be executed. Use the optional arguments, job name and job number, if you wish the program to run in the background. If you set the argument 'newmode', the results are displayed in a new window.
    Hope this will helps you.
    Regards,
    Sunitha.

  • How to run the program using specific classpath

    Recently I installed Javamail 1.2 and JAF1.0.1 on my NT Box and set up the classpath. I can compile my java email code by using: javac myEmail.java. But when I tried to run the code using java myEmail, it always gives the error: Exception in thread "main" java.lang.NoClassDefFoundError: myEmail.
    when I use -verbose and found that it always goes to:
    C:\Program Files\JavaSoft\JRE\1.3.1\lib\rt.jar to find classes even I use -cp option to point Javamail\mail.jar and activation.jar.
    what is wrong with it? Thank you in advance!!!!!!

    What does this have to do with JMS. I suggest that this should have been posted to the Java Programming forum where you would have gotten a quick response as this is a simple problem to diagnose.
    The problem is that the class myEmail, which you created, is not on the class path so it cannot find it. It has nothing to do with the location of mail.jar and activation.jar, although this may cause problems later.
    What you need to do is check the classpath in the environment variables section of the System dialog box. Make sure it refers to . (the current directory) as well as the locations of mail.jar and activation.jar. Also when you invoke myEmail ensure you are in the same directory.
    Hope this helps

  • Unable to run servlets on IWS 6.1

    I would like to use "anonymous servlets" (i.e. servlets not defined in web.xml file or in a war file) on IWS 6.1
    I could run servlets in this fashion on IWS 4.1 ve 6.0, however when I migrated my test server to IWS 6.1 I see servlet directory mappings are not present in this version of Iplanet, therefore my existing servlets did not run.
    Does anybody know how to use servlet in anonymous fashion? My servlets are in /servlet directory of server root.

    Right,
    I have now created a new SSID (e.g. GUEST2) for which I have set to use WPA, under express security I can see broadcast enabled for both SSID's, however this second ID cannot be seen by any of my devices. I have ticked the "Multiple BSSID Beacon" as Set SSID as Guest Mode.
    Nothing happens when I try to click the radio button "Multiple BSSID" for the two Radio's.
    Many thanks
    EC

  • Running two programs using two screens

    Hi, I have a 13” Mac Book Pro OSX 10.6.7 (2010) 2.26GHz 4GB I would like to work two programs using a second screen ie iTUNES on one screen and sound editing on the second. My second monitor is a 19” Toshiba HDTV that I can connect via the Mini display port to the HDMI on the monitor, is it possible for a third application by splitting one screen into 2. THXS

    TXTJ wrote:
    Hi, I have a 13” Mac Book Pro OSX 10.6.7 (2010) 2.26GHz 4GB I would like to work two programs using a second screen ie iTUNES on one screen and sound editing on the second. My second monitor is a 19” Toshiba HDTV that I can connect via the Mini display port to the HDMI on the monitor, is it possible for a third application by splitting one screen into 2. THXS
    I don't know about a TV used as a monitor but when using a monitor as a second monitor you can do what you want. You set up the display in extended mode. Start one of your applications and drag it over to the second monitor. Start your other application and don't drag it to the second monitor. You then have an application running on each monitor.

  • Xcode unabled to run any program (even Hello World default)

    I've started into programming c++ and java in Osx (come from linux) and i've tried xcode (after trying netbeans, eclipse etc) because i find it the most comfortable IDE to work.
    The problem comes when i download xcode on my own laptop, after the large download and installation (and few updates) i tried the basic Hello World program.
    What is my surprise when, after building succesfully, i get no output at all outputs sections, but more surprised when i try to stop running the program and xcode doesn't respond.
    I get this error with every program, doesnt matter which language.
    I also have a crash when quitting xcode (it freezes and colored ballon pointer appears), so i have to force xcode quit.
    Have anyone faced this issue before? or known whats the issue related with?
    I'll really appreciate any help (as i can't program anything in osx if i want to use xcode)

    From my Guest account it works perfectly.
    How can I make it works on my Account ? Which preference file should I need to change.
    Here is the message from the debugger
    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle </Users/USER/Library/Application Support/iPhone Simulator/7.1/Applications/A0D30F60-57F6-41C5-9EB0-E5FE46F50DB1/ToDoList.app> (loaded)'
    Thank you for your help

Maybe you are looking for