Ant: How to Install a Compiled Program (FOP 1.0) - java

The version of Ubuntu I use provides FOP 0.95. Its having problems, so I wanted to try the latest version of FOP. I successfully downloaded and built the sources.
Unfortunately, I can't figure out how to install FOP 1.0. The build instructions (https://xmlgraphics.apache.org/fop/1.0/compiling.html) did not cover the topic, and the README does not offer any instructions.
I naively tried ant install --prefix=/usr/local which failed. Ant listed its flags and switches, but did not include an install option. Next, I performed sudo cp ./fop /usr/local/bin, which resulted in the following
$fop -V
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/cli/Main
Caused by: java.lang.ClassNotFoundException: org.apache.fop.cli.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.apache.fop.cli.Main. Program will exit.
How does one install a program with Ant?
Jeff

Uncompress the download to a directory.
Add that directory to your path.
export PATH=~/tech/lang/java/fop/fop-1.0/:$PATH
That's it:
Daves-MacBook-Pro:~ Dave$ fop -V
USAGE
fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>
[OPTIONS]
-version print FOP version and exit
-d debug mode
-x dump configuration settings
# etc...

Welcome to the world of PATH and environment variables in Java.
The error is being caused because java cannot find the class libraries it requires.
You will find that fop is a script which invokes java with the appropriate parameters for this java application.
You also need to check your java installation and make sure everything is straight.

Related

How to run NegAIT with Stanford core nlp in Java in terminal in Mac?

I am not familiar with Java (only python). But I'd like to run NegAIT.
I have stanford core nlp 3.7 installed & downloaded the NegAIT repository. They're both in my home directory. I also have JDK SE 1.8 set as my home path.
When I ran the command on my Macbook terminal inside the NegAIT-master folder:
java -cp negate.jar:/Users/username/NegAIT-master/stanford-corenlp-3.7.0/stanford-corenlp-3.7.0.jar:/Users/username/NegAIT-master/stanford-corenlp-3.7.0/stanford-corenlp-3.7.0-models.jar negate.NegationParser AagenaesSyndrome.txt AagenaesSyndromeNegation
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/pipeline/StanfordCoreNLP
at negate.TextRead.<init>(TextRead.java:48)
at negate.NegationParser.main(NegationParser.java:21)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.pipeline.StanfordCoreNLP
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
As I said, I am familiar with Python but not with Java, if someone could help me out or give me a tip on how to run this tool I would highly appreciate it.
Stanford CoreNLP is not being found on your CLASSPATH. It looks like that is because you haven't substituted your login name for username in the paths in the -cp.
Or, if you are in running the commend inside the NegAIT-master folder, and the CoreNLP jar files are in a subdirectory stanford-corenlp-3.7.0 from there, you could simplify the CLASSPATH to:
java -cp negate.jar:stanford-corenlp-3.7.0/stanford-corenlp-3.7.0.jar:stanford-corenlp-3.7.0/stanford-corenlp-3.7.0-models.jar negate.NegationParser AagenaesSyndrome.txt AagenaesSyndromeNegation

Encountered error setting up plugins for Minecraft Nukkitx server on Raspberry Pi

RPI 2B, running Debian/Jessie, with java version 1.8.0_65.
Downloaded latest nukkitx from https://nukkitx.com.
Followed installation instructions at https://github.com/IntellectualCrafters/PlotSquared/wiki/Installation.
Plugins I have installed:
Plot Squared 18.07.21-aaa7088-2022
FastAsyncWorldEdit 18.07.21-a00345f-1159-20.4.0
DbLib 0.2.3
Error I am encountering:
java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open(Ljava/lang/String;I)V
Stack trace: https://pastebin.com/C3DrUm0Q.
Full server log: https://pastebin.com/2iuvQmbC.
As you can see, it says that PlotSquared has been loaded, but none of the plot commands are available. It just says unknown command when I type it. I have tried several different versions of all of the plugins, and a couple previous versions of nukkitx, all have the same problem. I'm thinking its something about my device, but I'm still pretty new to Linux and am not sure what to try next. Any suggestions would be amazing!
EDIT: I download the driver from https://github.com/xerial/sqlite-jdbc, and added it to the class path when calling the nukkitx jar to start the server. This didn't fix the problem. Here is the .sh file to start the nukkit jar:
#!/bin/sh
echo $USER
java -Xms1G -Xmx1G -cp ".;sqlite-jdbc-3.23.1.jar" -jar nukkit-1.0-SNAPSHOT.jar
I figured it out! For whatever reason, the JbLib sqlite driver apparently wasn't working. The solution was to remove JbLib (jar and folder) from the plugins folder, change the start.sh file (which I created according to the installation instructions) to use a classpath command instead of a jar command, add the xerial sqlite driver to the class path, and specify the Main Nukkit class to execute, like so:
java -classpath nukkit-1.0-SNAPSHOT.jar:sqlite-jdbc-3.23.1.jar cn.nukkit.Nukkit

Running Rake Tasks In WAS without JRuby

Related to : Executing rake tasks on an exploded war on tomcat without jruby being installed
I'm trying to run rake tasks in my Tomcat server that doesn't have JRuby installed. I'm using warbler to create a war file.
Using the answer to the linked question, I ran:
java -cp lib/jruby-core*.jar:lib/jruby-stdlib*.jar org.jruby.Main -S rake -T
This gets me the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
ls lib gets me:
ems-gems-activerecord-jdbc-adapter-1.2.2-lib-arjdbc-jdbc-adapter_java.jar
gems-gems-jdbc-sqlite3-3.7.2-lib-sqlite-jdbc-3.7.2.jar
gems-gems-jruby-jars-1.6.8-lib-jruby-core-1.6.8.jar
gems-gems-jruby-jars-1.6.8-lib-jruby-stdlib-1.6.8.jar
gems-gems-jruby-rack-1.1.10-lib-jruby-rack-1.1.10.jar
gems-gems-json-1.7.5-java-lib-json-ext-generator.jar
gems-gems-json-1.7.5-java-lib-json-ext-parser.jar
gems-gems-therubyrhino_jar-1.7.4-jar-rhino-1.7R4.jar
gems-gems-warbler-1.3.6-lib-warbler_jar.jar
jruby-core-1.6.8.jar
jruby-rack-1.1.10.jar
jruby-stdlib-1.6.8.jar
ojdbc6.jar
Opening up the jruby-core-1.6.8.jar file, I can see that there is indeed a org/jruby/Main.class file.
As one can see from the file listing, there is no jruby-complete jar file, so I can't run the command from https://stackoverflow.com/a/9982556/684934
What am I doing wrong, and is there by now a better way to do this?
I was working on a similar problem 2 months ago, so things may have changed, but I needed to include all the jars in my class path, had to use bin stubs, and had to set GEM_HOME to get everything working. It may have been simpler, but the posts you referenced didn't work for me either.
I actually had jruby installed, (but I was only using it to build the concatenated class path), so my setup was something like:
cd /path/to/application/
export GEM_HOME=/path/to/application/gems
export CLASSPATH=$(jruby -e 'puts Dir["lib/*.jar"].join(":")')
RAILS_ENV=production java -cp $CLASSPATH org.jruby.Main bin/rake -T
Also useful, the jruby-jars gem can be included in your gemfile to set the version of jruby that warbler includes (I was using gem 'jruby-jars', '1.7.0.preview2' as 1.7.0 wasn't released yet)

jdk1.7.0 installation on ubuntu 10.10

I am new to ubuntu 10.10 and am using it as VM. I tried installing jdk 1.7 to run java programs from terminal. I followed the instructions from the link: How to Install Oracle Java on Ubuntu Linux. After installation was complete, i tried to test run a Hello World java program. The program compiled successfully when i did javac Hello.java. However when i tried to run the program using java Hello, it didnt give any output on the terminal and gave me the following:
Unable to launch the application.
Exception:
CouldNotLoadArgumentException[ Could not load file/URL specified: Hello]
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Wrapped Exception
java.io.FileNotFoundException: Hello (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Further i tried checking my version for java using java -version and it gave the following output:
Java(TM) Web Start 10.0.0.147-fcs
Usage: javaws [run-options] <jnlp-file>
javaws [control-options]
where run-options include:
-verbose display additional output
-offline run the application in offline mode
-system run the application from the system cache only
-Xnosplash run without showing a splash screen
-J<option> supply option to the vm
-wait start java process and wait for its exit
control-options include:
-viewer show the cache viewer in the java control panel
-clearcache remove all non-installed applications from the cache
-uninstall remove all applications from the cache
-uninstall <jnlp-file> remove the application from the cache
-import [import-options] <jnlp-file> import the application to the cache
import-options include:
-silent import silently (with no user interface)
-system import application into the system cache
-codebase <url> retrieve resources from the given codebase
-shortcut install shortcuts as if user allowed prompt
-association install associations as if user allowed prompt
I see here that its using javaws when i try to run program using java.
I dont understand why this is happening or what is going wrong. Any help would be very much appreciated. Am just a beginner on Ubuntu.
Thanks in advance!!
Edit 1
Hello.java:
public class Hello
{
public static void main(String... s)
{
System.out.println("Hello World.!!!");
}
}
Your output from java -version give you the ouput from javaws -version.
So this seems to be a linking error in your filesystem.
If you use update-alternatives, you create a symbolic link in your binary-folder (/usr/bin).
Maybe you had some typo while going through the tutorial?
I'm pretty sure it was something like
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_05/bin/javaws" 1 or something like this.
You could try to reenter the "update-alternative" commands.
I am not sure you want 10.10 when 12.04 is available. I installed the Sun/Oracle version and it worked first time. All you have to do is download it, unpack it and add it to your path.
The error message suggests Java is not installed correctly.
I suggest you also install a free IDE like IntelliJ CE. This will make writing, compiling, running and debugging your application much easier.

run WEKA on Linux

I have downloaded and unzipped the following WEKA version weka-3-4-19. This is on a linux operating system. I wish to use WEKA through the command line, however on executing
java weka.classifiers.tress.j48.J48
I get the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tress/j48/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.tress.j48.J48
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: weka.classifiers.tress.j48.J48. Program will exit.
Can someone help me resolve this? Thank you.
Edit1:
On trying the java -jar weka.jar command
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.<init>(Window.java:432)
at java.awt.Frame.<init>(Frame.java:403)
at javax.swing.JFrame.<init>(JFrame.java:202)
at weka.gui.GUIChooser.<init>(GUIChooser.java:98)
at weka.gui.GUIChooser.main(GUIChooser.java:285)
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
Edit 2:
On trying java.weka.classifiers.trees.J48
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tress/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.tress.J48
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: weka.classifiers.tress.J48. Program will exit.
Edit 3:
{cslinux2:~/weka-3-4-19} echo $CLASSPATH
/people/cs/j/jld082000/weka-3-4-19/weka.jar:
{cslinux2:~/weka-3-4-19} java weka.classifiers.trees.J48
Weka exception: No training file and no object input file given.
General options:
-t <name of training file>
Sets training file.
-T <name of test file>
Sets test file. If missing, a cross-validation will be performed on the training data.
That simply means weka.classifiers.tress.j48.J48 class is not in classpath. You can write java command with -classpath switch or set CLASSPATH (permanent) variable. Another way is to use -jar switch as pointed by #jberg.
EDIT:
As I checked (I downloaded Weka 3-4-19 from that site) there is definitely no weka.classifiers.tress.j48.J48 class in weka.jar package. Probably you are looking for:
java weka.classifiers.trees.J48
For example:
$ export CLASSPATH=/home/grzegorz/weka-3-4-19/weka.jar:.
$ echo $CLASSPATH
/home/grzegorz/weka-3-4-19/weka.jar:.
$ java weka.classifiers.trees.J48
Weka exception: No training file and no object input file given.
General options:
-t <name of training file>
Sets training file.
...
This "weka.classifiers.trees.j48.J48" is a typo in the Weka documentation. It's should be this: "weka.classifiers.trees.J48"
And instead of setting the $CLASSPATH the alternative is just to put:
java -cp /pathto/weka.jar weka.classifiers.trees.J48
Also, you might want to give it more memory to play with, to speed things up:
java -Xmx1G -cp /pathto/weka.jar weka.classifiers.trees.J48
For running a classifier (like you are attempting to do) you need to at least give it some data, which must already be converted to ARFF format.
To run a test on some data enter:
java -Xmx1G -cp /path/to/weka.jar weka.classifiers.trees.J48 -t /path/to/whatever.arff
-t is for training file.
See here:
Weka Primer
I haven't used WEKA on linux, but I think it is just packaged as a jar file, so you want to:
java -jar weka.jar
You can also use the weka source jars to use the classifiers in your own code by including it in your build path like you would other jars.
I run the Linux Developer version in macOS. You can copy the .bash_profile below and modify to your needs.
As I answered here, you can just put the following to your ~/.bash_profile
export R_HOME="/Applications/R.app/Contents/MacOS/R" #for WEKA MLR R plugin
export CLASSPATH="/Applications/weka-3-9-1/weka.jar" #for WEKA commandline
export WEKAINSTALL="/Applications/weka-3-9-1"
export WEKA_HOME="/Applications/weka-3-9-1"
export CLASSPATH=$CLASSPATH;$WEKA_HOME/weka.jar
export HEAP_OPTION=-Xms4096m -Xmx8192m
export JAVA_COMMAND java $HEAP_OPTION
after this and refreshing the terminal, you should be able to run the following command
java weka.classifiers.trees.J48 -t $WEKAINSTALL/data/iris.arff

Categories