0

How can I use Java classes from a "plain" Eclipse Java project inside a a Google Web Application project (i.e. a project created with Google Plugin for Eclipse)? If I add the plain project to the web application project's build path this does not lead to its classes being copied into the war file, so things work out only at compile time (build path is set), but not at runtime (classes remain outside scope of classpath on server).

I realize that the question may not be specific to Google Web Application projects as such but refer to code (library) sharing between J2EE projects inside Eclipse as a whole. I am using the Google Plugin for Eclipse with Eclipse Kepler. So is the problem perhaps that I am not using the standard version of Eclipse, not its version for Java EE Developers?

Drux
  • 11,992
  • 13
  • 66
  • 116
  • Possible duplicate [here](http://stackoverflow.com/questions/9393278/using-workspace-projects-with-appengine). – Drux Jan 14 '14 at 17:27

1 Answers1

0

Google Web Application structure follows the standard J2EE WAR structure.

There are various ways you can use external classes in your Google App Engine project:

  • Copy the source files under the src directory and they should all compile fine and be available when you run locally and deploy.

  • If you have your external classes packaged as a jar file, just drop the jar file into the WEB-INF\lib folder and in your Java Build Path, point to the JAR file that you have placed in the WEB-INF\lib folder.

  • If you have .class files, they can be put in the WEB-INF\classes folder but I suggest that you preferably package all your .class files into a JAR file and follow the above step.

The above steps should meet your requirements. Just note one thing that certain JRE classes are not allowed in App Engine, so you should make sure that the external classes that you plan to use in your Google App Engine web application do not violate that. Refer to the JRE White List.

Romin
  • 8,708
  • 2
  • 24
  • 28
  • All of this is fine, but I would expect Eclipse tooling to do that for me. After all, it knows all dependencies from the build path setup. Or am I missing something? – Drux Jan 14 '14 at 17:22
  • I dont think Eclipse is going to add the files to WEB-INF\lib or any other deployment directory just because they have been added to the Build Path. You have to place them. – Romin Jan 15 '14 at 01:06
  • I meanwhile did so relying on [information](http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-93_project_builder.htm) found in the linked [duplicate](http://stackoverflow.com/questions/9393278/using-workspace-projects-with-appengine) question, but I still wonder why this isn't automated by Eclipse. – Drux Jan 15 '14 at 03:35