I have found that the "from <package> import <class>" syntax doesn't work in some instances in Jython. try:

import com.pojo.util.User
# User = com.pojo.util.User
...

Just uncomment out the 2nd line if you want to be able to use User correctly. It is a workaround, but it works. I pass pojos to Jython all the time, as I tend to use Jython in more of a providing an embedded scripting language for my Java apps kinda way.

On Thu, May 20, 2010 at 12:32 PM, Regula, Prasad <prasad.regula@twcable.com> wrote:

I need to pass Java POJO's as parameter to the java class I would be calling from Jython. I declared a java project and created a pojo, under the package com.pojo.util and the pojo name is User. I created an python project and wrote the following code

from com.pojo.util import User
class PojoTest:
user = User();
user.setFname("Mike");
user.setLname("Springer");
print user.getFname(), user.getLname()


It is saying
Traceback (innermost last):
File "__init__.py", line 1, in ?
ImportError: no module named pojo

My main target is "Passing of Java pojo's instead of simple int or Strings as parameters to Jython functions".

 

Thanks

Prasad Regula

 

This E-mail and any of its attachments may contain Time Warner
Cable proprietary information, which is privileged, confidential,
or subject to copyright belonging to Time Warner Cable. This E-mail
is intended solely for the use of the individual or entity to which
it is addressed. If you are not the intended recipient of this
E-mail, you are hereby notified that any dissemination,
distribution, copying, or action taken in relation to the contents
of and attachments to this E-mail is strictly prohibited and may be
unlawful. If you have received this E-mail in error, please notify
the sender immediately and permanently delete the original and any
copy of this E-mail and any printout.

------------------------------------------------------------------------------


_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users




--
"I'm not responcabel fer my computer's spleling errnors" - Xlorep DarkHelm
Website: http://darkhelm.org