0

Possible Duplicate:
java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0

I'm trying to learn basics of writing a simple jsp/servlet web application with no IDE/build tool etc. Just a text editor and a command line. I have some .jsps that are using a couple Java classes that I wrote. Here is a snippet from the jsp called display_email_entry.jsp

        <%
        //get parameters from the request
        String firstName = request.getParameter("firstName");
        String lastName = request.getParameter("lastName");
        String emailAddress = request.getParameter("emailAddress");

        //get the real path for the EmailList.txt file
        ServletContext sc = request.getServletContext();
        String path = sc.getRealPath("/WEB-INF/EmailList.txt");

        //use regular java objects
        User user = new User(firstName, lastName, emailAddress);
        UserIO.add(user, path);
    %>

So I am doing all of this bare bones, just using a text editor and trying to understand how to compile this from the command line and then deploy it to tomcat manually. But I don't know what to do to generate the .class files from the .java files and get them into WEB-INF/classes and have this little practice application run.

My current file structure looks like this:

User ->
  index.html
  display_email_entry.jsp

  business ->
    User.java
  data ->
    UserIO.java

  WEB-INF ->
    web.xml
  classes (currently empty)

I've tried to go do this:

javac -d WEB-INF/classes data/UserIO.java

Which generates class files for me, but when I try to run it on the web server I am getting the following error.

HTTP Status 500 - javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: business/User : Unsupported major.minor version 51.0 (unable to load class business.User)

So I'm kinda stuck. I'm hoping someone can point out what I'm doing wrong here. Thanks in advance.

Community
  • 1
  • 1
pipplupp
  • 219
  • 2
  • 4
  • 8
  • 3
    The server is running under a different version of java than you're compiling with. I think what you're doing is a good exercise; I wish more people would start from scratch for awhile. – Dave Newton Oct 17 '12 at 23:17
  • Thanks Dave. Yep, that was the problem. Tomcat was looking at an older version of Java. I fixed it by setting JAVA_HOME in setenv.sh. – pipplupp Oct 19 '12 at 00:07

0 Answers0