I am currently creating a discord bot in Java and decided to write a script in python as it had libraries that proved very useful for web scraping. By using Jython, I was able to run the script. The bot successfully came online, however, it resulted in the following:
ImportError: No module named praw
When I run the python script by itself in another IDE, it works perfectly. I was wondering if I have to add praw as a dependency in gradle? Suggestions are appreciated.
If you're using python 3 you need to use pip3 when installing packages
$ pip3 install praw
Related
Context
I need to utilize Websockets, but the ancient version of PHP we're using doesn't support them. I've decided to try a Java Websocket server. I've written a handful of Android applications in Android Studio, so I'm familiar with the basic syntax of Java, but have very little experience compiling and running java-things manually.
I'd like the server to be a single file that I can run once from the command line and forget about. To that end, I've decided to use this library which includes a Javascript chat app in the examples. I'm having trouble compiling and running the server for the example.
I'm on a Mac.
What I tried
Copy the server (src/main/example/ChatServer.java) to the directory with the rest of the dependencies (/src/main/java/org/java_websocket/).
Move into the library directory: cd ./src/main/java/org/java_websocket/
compile all library .java files and the ChatServer file into a jar: jar cfv ChatServer.jar *
Run it: java ChatServer
Receive error:
Error: Could not find or load main class ChatServer
Question
How can I compile ChatServer.java with all the dependencies into a single file that can be copied to the server and executed with a single command?
Use Maven or Gradle. Since you've done Android apps, you're probably familiar with Gradle, so I'd recommend trying that one first.
I'm working on CentOS 6.5, with Jenkins running. I've installed Robot framework plugin for jenkins, installed python 2.7 with Robot Framework (pybot works). I also wrote pretty easy program using NetBeans maven project with one unit test. My goal is to use RF in order to run said test.
At first i've tried to use Python version of RF, but eventually did it with jar stand-alone.
So my questions are:
1. Is it possible to add java libraries with keywords to Python version of RF or do i have to use jar stand-alone?
2. If i have to use .jar stand-alone, how can i run working test case on jenkins?
I've literally tried everything that i've found on this site (that's why eventually test-case worked), but i couldn't find anything else specificaly about what i'm asking.
You can use Jar edition with jenkins by using execute shell command
java -jar robotframework-3.0.jar -P TestedJarName.jar -d FolderForLogs RobotScript.txt
This will let you run test script. In script, you have to specify library with keywords - in other words, where in package is you .java file. For example, if you want to test Main.java that is in com.main package, you must write
Library com.main.main
Now, you can use all methods from Main.java
If you want just python script that runs maven tests, you just run it through shell pybot testname.txt
In text u need something like that Run mvn test and that's all.
I Have a java application.I want to run the matlab script from java. Is it possible to run matlab script without installing matlab but only using the matlab jar file in my application.
Please give some links or some inputs.
In one of my academic projects I used the following link and it works.
http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html
I usually compile and execute from Java project using eclipse IDE. Now, I need to write a bash script to submit this task to a cluster. My project contains 3 packages and has been written as per the Maven architecture. Can anyone hint me as to how can I include the task of executing the java program in the my bash script?
I tried different things like first trying to execute the project using command line but it does not work. I already read the replies provided in this post: Compiling and running multiple packages using the command line in Java and some others, but didn't help.
Thank you for your help.
I strongly suggest you look into something like the Maven App Assembler plugin. I don't know about your cluster but the mentioned plugin can create run scripts for most major OSes and is highly configurable.
Am trying to execute a complete Jython project using java eclipse 3.4.. I have configured Jython environment in my eclipse..I went through certain tutorials which described about Building a factory.. But i guess that method can be used to execute applications that are specific to a particular Jython module.. What I exactly need is::
To run the entire Jython project as a java application, by using the .class file created in the Jython project..
Not sure if this is feasible.. Suggestions please..
One Java class with an embedded PythonInterpreter is capable of kicking off an entire Jython application. May need to play around with setting the appropriate python.home and library paths, look in the PyServletInitializer and PyFilter for examples of how this is done.
Another option is use PyDev and just run a Jython script to start the application, bypassing the need for a Java application all together.