Reputation: 171
I wrote a java file named jug.java that uses jython and PythonInterpreter; this is the code:
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);
}
}
when I try executing it using this command:
javac Jug.java
These error occur:
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
Also jython is installed. How can I solve that error?
MORE INFORMATION
Already I have installed jython using terminal:
sudo apt install jython
It successfully installs jython. But whenever I try to install it from source:
sudo java -jar jython-installer-2.7.0.jar
These error occur:
#
# 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)
Upvotes: 2
Views: 2687