我来自Java世界,对Jython来说是全新的.
是否可以在Eclipse中使用同一项目中的Jython和Java类创建项目?我尝试这样做 - 编写一个简单的Java类并在Jython模块中使用它 - 在编码过程中一切都很顺利.但当我尝试运行该项目时,我得到:
Traceback (most recent call last):
File "/home/bahman/Work/Jython/TestJython/src/com/bahmanm/Main.py", line 1, in <module>
from com.bahmanm import Greeter
ImportError: cannot import name Greeter
Run Code Online (Sandbox Code Playgroud)
Java类是:package com.bahmanm;
public class Greeter {
private String msg;
public Greeter() {
msg = "Hello, ";
}
public void greet(String name) {
System.out.println(msg + name);
}
}
Run Code Online (Sandbox Code Playgroud)
而Jython模块非常简单:
from com.bahmanm import Greeter
g = Greeter()
g.greet("Bahman")
Run Code Online (Sandbox Code Playgroud)
我很感激任何想法/提示.
归档时间: |
|
查看次数: |
3030 次 |
最近记录: |