|
|
|
|
|
Re: Trying to get Eclipse + Tomcat + Groovy to work [message #227604 is a reply to message #227578] |
Tue, 10 February 2009 21:25 |
Mike Schwager Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Sorry, I think there's some confusion here. I'm sure the Groovy Libraries
don't contain a com.schwager class (or package for that matter).
The KMLbuilder2.groovy file is being edited within the same source tree
(ie, the same package) as the Play.java file. That Groovy file is what
I'm trying to create right now.
When I edit files in Eclipse, I don't need to compile my .java files into
a jar and then include that jar in the build library set... my .java files
are exactly what I'm working on in Eclipse, and then the IDE is kind
enough to create the .class files and run my project when I ask it to.
I want to continue to do the same thing; however, it happens that I have a
file with a .groovy suffix, I've included the Groovy nature, I'm using the
Groovy syntax, and I am including the Groovy jar files. (In short, once
the .class files are created none of that should matter- it's just another
class but it got generated utilizing the Groovy nature).
So though I'm not working on the libraries, I need them in order to run,
natch. But what I AM working on and need help with are:
- Play.java - a standard Java class
- KMLbuilder2.groovy - a Groovy class.
Both of these files are in my Play(project)->src->com->schwager package.
"Play" instantiates an KMLbuilder2 object, which has but one method. The
whole KMLbuilder2 Groovy class looks like this:
package com.schwager
public class KMLbuilder2{
public String build () {
return '''
<html><body>Hello Jackson 5</html></body>
'''
}
}
It is called from a very simple java servlet, created in Eclipse, from
this method in Play.java:
(everything else in this class is boilerplate trivial Java servlet,
Eclipse-created code)
...
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
KMLbuilder2 KMLbuilder2=new KMLbuilder2();
byte[] result=KMLbuilder2.build().getBytes();
OutputStream output=response.getOutputStream();
output.write(result);
output.flush();
}
...
As it turns out, though, you got me going on the right path. I have
figured it out as I've typed this. What I needed to do was:
1. Go to my Project properties
2. Select "Java build path"
3. Observe the "Default output folder", which in my case is
"Play/build/classes"
4. Select "Groovy Project properties"
5. Change the "Groovy compiler output location" to be the same output
folder, minus the Project name. Thus for me, it would be "build/classes".
In this way, Eclipse puts all the .class files in the same directory.
Then when the servlet gets built, all the .class files I need are included.
Naturally, the groovy libraries need to be included (as you mentioned) in
the Java EE Module Dependencies.
Thanks again, I'm on the right track now I feel.
|
|
|
Powered by
FUDForum. Page generated in 0.02265 seconds