jythonを使用してPythonで実行したいJavaでクラスを作成しました。最初に私が得ているエラーは?
Traceback (most recent call last):
File "/Users/wolverine/Desktop/project/jython_scripts/customer.py", line 3, in <module>
customer = Customer(1234,"wolf")
TypeError: No visible constructors for class (Customer)
私のJavaクラスのフォーマット:
public class Customer {
public final int customerId;
public final String name;
public double balance;
/*
* Constructor
*/
Customer(int _customerId, String _name){
customerId = _customerId;
name = _name;
balance = 0;
}
私のpython 2行スクリプト
import Customer
customer = Customer(1234,"wolf")
print customer.getName()
ディレクトリ構成はこんな感じ
folder/customer.py folder/Customer.java folder/Customer.jar
私はフォルダに行きました
%javac -classpath Customer.jar *.java
そして、私のjythonはUsers/wolverine/jython/jythonにあります
実行するには、これを行います
%/Users/wolverin/jython/jython ~/Desktop/folder/customer.py
また、エラーは次のとおりです。
Traceback (most recent call last):
File "/Users/wolverine/Desktop/project/jython_scripts/customer.py", line 3, in <module>
customer = Customer(1234,"wolf")
TypeError: No visible constructors for class (Customer)
免責事項。Javaを使い始めたばかりです:(