0

I'm completely new to J2EE and my boss said to me to make a web page quickly based on J2SE project I worked on.
So, I started from Hello example, then tried to use J2SE project right into J2EE project.
I used eclipse and in property-java build path-projects of J2EE project, I added all the J2SE project related with my job, and created a Java class that invokes J2SE class.
Then I add jsp like this

<%@ page import="package.classNameHere" %>
<%
    classNameHere tc = new classNameHere();
    tc.mainRun();
%>

mainRun looks like this

public void mainRun() {
    try {
        new J2EEClassThatInvokesJ2SEClass(); // I changed name
     } catch (Exception e) { // exception is needed
        throw new RuntimeException(e);
     }
}

(I changed class name for security problem)
but it occurs this error

Servlet.service() for servlet [jsp] in context with path [/package] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: (Another class that I added from property)] with root cause


Is it unavailable to run J2SE class from J2EE project?

Prunus Nira
  • 107
  • 1
  • 1
  • 11
  • You need to deploy your J2SE classes (ideally as JAR file) to your servlet container, either in the `WEB-INF/lib` directory of your webapp, or in the shared lib derectory of the servlet container (not recommended). – Jozef Chocholacek Jul 10 '15 at 10:05
  • Please, "J2SE" and "J2EE" died 2006, almost a decade ago. Make sure that you aren't learning Java SE and Java EE based on heavily outdated resources. – BalusC Jul 10 '15 at 11:09

0 Answers0