2017-07-30 16 views
0

jythonとPythonInterpreterを使用するjug.javaというJavaファイルを作成しました。これはコードです:Jythonクラスが見つかりません

import org.python.util.PythonInterpreter; 
import org.python.core.PyObject; 

public class Jug{ 
    public void main(String[] args) { 
     PythonInterpreter interpreter = new PythonInterpreter(); 
     interpreter.exec("import InstaFeed\nAPI=InstaFeed.InstaFeed(someusername, somepassword)"); 
     PyObject someFunc = interpreter.get("API.like(mediaId"); 
     PyObject result = someFunc.__call__(new PyInteger(15)); 
     String realResult = (String) result.__tojava__(String.class); 
    } 
} 

私は、このコマンドを使用して、それを実行してみてください。

javac Jug.java

これらのエラーが発生します。

Jug.java:1: error: package org.python.util does not exist 
import org.python.util.PythonInterpreter; 
        ^
Jug.java:2: error: package org.python.core does not exist 
import org.python.core.PyObject; 
        ^
Jug.java:6: error: cannot find symbol 
     PythonInterpreter interpreter = new PythonInterpreter(); 
     ^
    symbol: class PythonInterpreter 
    location: class Jug 
Jug.java:6: error: cannot find symbol 
     PythonInterpreter interpreter = new PythonInterpreter(); 
              ^
    symbol: class PythonInterpreter 
    location: class Jug 
Jug.java:8: error: cannot find symbol 
     PyObject someFunc = interpreter.get("like"); 
     ^
    symbol: class PyObject 
    location: class Jug 
Jug.java:9: error: cannot find symbol 
     PyObject result = someFunc.__call__(new PyInteger(15)); 
     ^
    symbol: class PyObject 
    location: class Jug 
Jug.java:9: error: cannot find symbol 
     PyObject result = someFunc.__call__(new PyInteger(15)); 
               ^
    symbol: class PyInteger 
    location: class Jug 
7 errors 

はまたのJythonがインストールされています。 どうすればそのエラーを解決できますか?

詳細

すでに私がインストールされているJythonを使用してターミナル:それは成功したのJythonをインストール

sudo apt install jython 

。 しかし、私はソースからインストールしようとするたび:

sudo java -jar jython-installer-2.7.0.jar 

これらのエラーが発生します。

# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# SIGSEGV (0xb) at pc=0x00007f0f6e654009, pid=31088, tid=31089 
# 
# JRE version: OpenJDK Runtime Environment (9.0) (build 9-internal+0-2016-04-14-195246.buildd.src) 
# Java VM: OpenJDK 64-Bit Server VM (9-internal+0-2016-04-14-195246.buildd.src, mixed mode, tiered, compressed oops, g1 gc, linux-amd64) 
# Problematic frame: 
# C [libjava.so+0x1d009] JNU_GetEnv+0x19 
# 
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/muhammad/Downloads/core.31088) 
# 
# An error report file with more information is saved as: 
# /home/muhammad/Downloads/hs_err_pid31088.log 
# 
# If you would like to submit a bug report, please visit: 
# http://bugreport.java.com/bugreport/crash.jsp 
# The crash happened outside the Java Virtual Machine in native code. 
# See problematic frame for where to report the bug. 
# 
Aborted (core dumped) 

答えて

1

パッケージorg.python.utilは、あなたが

にあなたが欠落しているjython.jarに存在している必要がありますjython

存在する場合は、コマンドに追加してください(javac Jug.javaの代わりに)

java -cp jython.jar:. Jug 
+0

ソースからインストールすることはできません。追加したばかりの情報を読んでください。 –

+0

java -cp jython-installer-2.7.0.jar:を呼び出してみましたか。ジャグ? – user7294900

+0

はい、出力:エラー:メインクラスを見つけられないまたはロードできません –

関連する問題