Javauto Compile fails (Getting started) - java

Following Getting started -
(Windows 7, console: C:...>, .jar & .javauto in the same folder)
java -jar javauto.jar => OK, help is displayed
javauto hello.javauto => command not recognised
javauto.jar hello.javauto => NO result
So i tried this
java -jar javauto.jar -v hello.javauto
Giving this exception (NB: c:...>javac => help display is OK)
Generating ←[92mhello←[0m...
Getting user imports... None
Getting user global variables... None
Getting user functions... None
Generating functions... ←[93mmouseMove ←[0m←[93mmsgBox ←[0m←[93mprint ←[0m←[93msleep ←[0m
Generating class variables... ←[93msimulatedMotionSpeed ←[0m
Generating imports... ←[93mAWTException ←[0m←[93mMouseInfo ←[0m←[93mRobot ←[0m←[93mJDialog ←[0m←[93
mJOptionPane ←[0m
Generating struct objects... None
Generation complete... starting build
Executing cmd /c attrib +s +h "C:\Users\Francis\Develop\java\Javauto\.hello"...
Building ←[92mC:\Users\Francis\Develop\java\Javauto\.hello\class\hello.class←[0m...
Exception in thread "main" java.lang.NullPointerException: Couldn't find java system compiler.
at com.automation.javauto.compiler.CustomJavaCompiler.compile(CustomJavaCompiler.java:36)
at com.automation.javauto.parser.Create.main(Create.java:419)

Try this:
1) Compile it using this command:
java -jar javauto.jar hello.javauto
2) Now that you have compiled your program, there will be a file called hello.jar. Execute with:
java -jar hello.jar

Related

Java: Class not found for PageRank algorithm in Apache Hadoop

I am trying to run PageRank algorithm in Apache Hadoop (2.6.5) cluster (1 master 2 slaves). I am using the program in this repository - https://github.com/danielepantaleone/hadoop-pagerank.git. I was able to compile all the sources using this command -
sudo javac -classpath ${HADOOP_CLASSPATH} -d ./build src/it/uniroma1/hadoop/pagerank/PageRank.java src/it/uniroma1/hadoop/pagerank/job1/PageRankJob1Mapper.java src/it/uniroma1/hadoop/pagerank/job1/PageRankJob1Reducer.java src/it/uniroma1/hadoop/pagerank/job2/PageRankJob2Mapper.java src/it/uniroma1/hadoop/pagerank/job2/PageRankJob2Reducer.java src/it/uniroma1/hadoop/pagerank/job3/PageRankJob3Mapper.java
I created the jar file using this command sudo jar -cf build/pagerank.jar build/.
I am trying to run the program just like the wordcount example like this -
sudo bin/hadoop jar hadoop-pagerank/build/pagerank.jar PageRank --
input /usr/local/hdfs/web-Google.txt --output /usr/local/hdfs-out-PR
Sometimes I get an error like this -
Exception in thread "main" java.lang.NoClassDefFoundError: PageRank (wrong name: it/uniroma1/hadoop
/pagerank/PageRank)
and sometimes I get an error like this - Exception in thread "main" java.lang.ClassNotFoundException: PageRank for different types of compilation.
I am not sure what am I doing wrong. Can anyone please help me in proper steps to compile and run the program in Hadoop ? I dont have any pom.xml file and I am able to run the provided wordcount example jar.
You have to use package name before the name of the class,
it means you have to use :
it.uniroma1.hadoop.pagerank.PageRank
rather than PageRank
in your command.
like this :
hadoop jar hadoop-pagerank/build/pagerank.jar it.uniroma1.hadoop.pagerank.PageRank --input /usr/local/hdfs/web-Google.txt --output /usr/local/hdfs-out-PR

linux - how to run a selenium-server-standalone?

I created a .sh file with the following content:
java -jar selenium-server-standalone-3.3.1.jar -Dwebdriver.gecko.driver=./opt/webdrivers/geckodriver
I already made sure that the file /opt/webdrivers/geckodriver has permission to get executed by using chmod 770 and I even changed the user to root.
But this is the result if I execute my .sh file:
root#mycomputer:/opt/Selenium# ./selenium.sh
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -Dwebdriver.gecko.driver=./opt/webdrivers/geckodriver
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$1.setConfiguration(GridLauncherV3.java:227)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:155)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:75)
What am I doing wrong?
You have to specify the parameters right after -jar:
java -jar -Dwebdriver.gecko.driver=./opt/webdrivers/geckodriver selenium-server-standalone-3.3.1.jar
Note: This is a knowledge sharing answer (share your knowledge, Q&A-style)

Need to move on after java error when Python script uses subprocess to run a java program

In a python2.7 script, I'm using subprocess.call to run a java program like this:
java_command = "java -jar /path/to/java_program.jar %s %s >> %s" % (infile, outfile, logfile)
subprocess.call(java_command, shell=True)
...
#Do other stuff unrelated to this output
Most of the time, this works fine, but in some cases the java program errs:
Exception in thread "main" java.lang.NullPointerException
at MyProgram.MainWindow.setProcessing(MainWindow.java:288)
The problem is that my python script is then stalled on the subprocess.call() line and can't do the "other stuff".
Is there a way I can edit either the java_command I'm using or the way I'm using subprocess to continue the python script even when the java program hangs?
Note that I can't modify the java program's code.
I think you want the check_call method from that same package:
try:
status = subprocess.check_call(java_command, shell=True)
except CalledProcessError as e:
# The exception object contains the return code and
# other failure information.
... react to the failure and recover

Error: java.lang.NoClassDefFoundError when running java from NodeJs

I'm trying to execute a jar file from nodeJs, I've been using both child_proces.exec and child_process.spawn. with both cases I'm receiving this error:
Error: Exception in thread "main"
Error: java.lang.NoClassDefFoundError: com/ftdi/FTDevice
I'm using ubuntu 14.04 with java, jdk, etc' installed.
Here is my code:
using exec:
var exeprocess = exec('java -Djava.library.path=./ftd2xx.so -jar DenkoviRelayCommandLineTool_10.jar DAE000dY 4 2 1');
using spawn:
var proc = spawn('java',
[ '-jar',
'-Djava.library.path=./ftd2xx.so',
'DenkoviRelayCommandLineTool_10.jar',
'DAE000dY ','4','2','1'
]);
I've figure out that both cases can't locate classes in ft2xx.so, but why?
b.t.w: double check that the command/locations are correct and the exact same script work perfectly in terminal
You will need to add -classpath <path of jar>/JavaFTD2XX-0.2.5.jar to your exec or spawn to avoid NoClassDefFoundError.

Calling Java from PHP vs shell - java.lang.NoClassDefFoundError:

I have two java classes that reside in .../jtest/StepRegTest directory and include "package StepRegTest;" directive.
Option 1. I call it directly from shell:
[jtest]# java StepRegTest.Main
Everything works fine.
Option 2. I call java via PHP exec:
<?php
echo getcwd() . "\n";
exec("java StepRegTest.Main 2>&1", $output);
print_r( $output );
?>
The PHP file is in the same directory jtest as for the Option 1, when I call it from the shell. However, it returns an error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/quinncurtis/matpackjava/DMatBase
The jar archive that refers to these missing classes is in the CLASSPATH.
The import reference for that class is:
import com.quinncurtis.matpackjava.DDMat;
Note that everything works fine when I execute the code from the shell.
What is the problem here? Why does it work from the shell, but not from PHP?
Thanks!
If the CLASSPATH environment variable is being used, verify it's set at the time the php exec() call is made; it may be getting lost.
One easy way to check is this:
<?php
echo getcwd() . "\n";
exec("env", $output);
print_r( $output );
?>
To set the CLASSPATH variable in the php script, the following can be done:
putenv("CLASSPATH=/path/to/lib.jar");
Here's a page that describes putenv():
http://php.net/manual/en/function.putenv.php

Categories

Resources