-3

This is first class myservlet.java i am calling it to compute using another code named compute.java which calls the functions the entire operation is done via an R code at the bcak end the link for tht file is given in the compute class .

An error named ClassNotFoundException is abrupting the program .

MyServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response) 
                  throws ServletException, IOException  //this where i am getting the error

    Compute c=new Compute(a1,a2); //sometimes error is mentioned here

I am getting an error at these 2 lines of code particularly

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Posting full stacktrace and full code MyServlet and Compute classes would make it easier for someone to help you. – pleft Feb 09 '16 at 10:14

1 Answers1

0

seems like there are multiple possible reasons:

  • is your "Compute"-class actually named "compute.java", as you wrote? Or "Compute.java", which would be correct - considering that, according to certain java conventions, class names always start with a capital letter. aside from that, you wrote Compute in the code with a capital letter as well.
  • are both classes in the same project? if not, either move them so they are, or import the package that contains "Compute.java" in the class "Myservlet.java" by adding:

    import packagename.Myservlet;

You will also have to add the project that contains Compute.java to your java build path. To do so, right click on your project > Properties > Java Build Path. If the classes are in different packages, but in the same project, you can ignore this step.

PixelMaster
  • 895
  • 10
  • 28
  • Its named as u said compute.java and also classes are in the same package but I am unable to link them with R coding – Aditya Samant Feb 10 '16 at 05:58
  • what I meant to point out is that java is case sensitive. If your class name actually starts with a lower case letter (which it should NOT, according to certain conventions), you can't create a new instance of the class by calling "Compute x = new Compute()". you see, in java, `Compute ≠ compute` – PixelMaster Feb 10 '16 at 09:56