Error setting classpath - java

I want to run an automated test-case generation tool on the class Realm.java of project Async-HTTP-Client.
I located its path:
[dario#bob async-http-client]$ find /home/dario/async/553/prefix -name Realm.java
/home/dario/async/553/prefix/async-http-client/api/src/main/java/org/asynchttpclient/Realm.java
Hence set the classpath to:
[dario#bob async-http-client]$ echo $CLASSPATH
/home/dario/async/553/prefix/async-http-client/api/src/main/java:/home/dario/async/553/prefix/async-http-client/evosuite-tests:/home/dario/testEnv/684131/prefix/rhino/lib/xbean.jar:/home/dario/evosuite/target/evosuite-0.1-SNAPSHOT-jar-minimal.jar
But when I run the command to generate tests:
[dario#bob async-http-client]$ ~/evosuite/target/bin/EvoSuite -class org.asynchttpclient.Realm -projectCP /home/dario/async/553/prefix/async-http-client/api/src/main/java:/home/dario/testEnv/684131/prefix/rhino/lib/xbean.jar
* EvoSuite 0.1-SNAPSHOT
* Unknown class: org.asynchttpclient.Realm
I am told the class is non-existent.
Ideas?

As far as Google revealed EvoSuit needs the compiled class.
My guess is that you eighter didn't compile the class or it landed in a different directory.

Related

Running Java test in command line : test class files in a different directory than source files

I have a project where test source files are in target/test-classes and source files are in target/classes.
I want to run the tests in command line. I use this command :
java -cp "target/test-classes:target/dependency/*" org.junit.runner.JUnitCore com.java.MyClassTest
But this rises an error because Junit cant find com.java.MyClass (which is tested by com.java.MyClassTest).
There was 1 failure:
initializationError(org.junit.runner.JUnitCommandLineParseResult)
java.lang.IllegalArgumentException: Could not find class [com.java.MyClassTest]
So I try :
java -cp "target/classes:target/dependency/*" org.junit.runner.JUnitCore com.java.MyClassTest
But then Junit cant find com.java.MyClassTest :
There was 1 failure:
initializationError(com.java.MyClassTest)
java.lang.NoClassDefFoundError: Lcom.java.MyClass;
Do you know how to solve this whithout moving classes and/or using Maven?
Thank you in advance,
Abdelghani

Apache Storm - Could not find or load main class org.apache.storm.starter.ExclamationTopology

I'm really new to maven and storm so I'm trying to follow the instructions in https://github.com/apache/storm/tree/master/examples/storm-starter. My current path is /home/luc/theTest/storm/examples/storm-starter. Inside the target folder there is a storm-starter-2.0.0-SNAPSHOT.jar file. I'm getting stuck when running
storm jar target/storm-starter-*.jar org.apache.storm.starter.ExclamationTopology -local
I get this error
ionTopology -local
Running: /usr/lib/jvm/java-8-openjdk-amd64/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/home/luc/stormTest/apache-storm-1.1.1 -Dstorm.log.dir=/home/luc/stormTest/apache-storm-1.1.1/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /home/luc/stormTest/apache-storm-1.1.1/lib/servlet-api-2.5.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/slf4j-api-1.7.21.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/objenesis-2.1.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/kryo-3.0.3.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-core-2.8.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-over-slf4j-1.6.6.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/storm-core-1.1.1.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/minlog-1.3.0.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/log4j-api-2.8.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/clojure-1.7.0.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/ring-cors-0.1.5.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/asm-5.0.3.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/reflectasm-1.10.1.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/disruptor-3.3.2.jar:/home/luc/stormTest/apache-storm-1.1.1/lib/storm-rename-hack-1.1.1.jar:target/storm-starter-2.0.0-SNAPSHOT.jar:/home/luc/stormTest/apache-storm-1.1.1/conf:/home/luc/stormTest/apache-storm-1.1.1/bin -Dstorm.jar=target/storm-starter-2.0.0-SNAPSHOT.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} org.apache.storm.starter.ExclamationTopology -local
Error: Could not find or load main class org.apache.storm.starter.ExclamationTopology
Am I doing something wrong? I'm also a bit confused on whether I have to run the nimbus and supervisor first. I tried with and without them and neither worked anyways. Been searching the web but nothing works. Not sure what else to try.
This is usually caused by inconsistent versions of storm-client and storm-starter. Try following these steps to get the example working.
download the latest release from http://storm.apache.org/downloads.html
in this example, we will use version 1.1.1
extract this to a folder, lets call it ${STORM_HOME}
cd into ${STORM_HOME}/examples/storm-starter
execute mvn package -DskipTests=true
this should build the storm-starter jar in target folder
${STORM_HOME}/examples/storm-starter/target/storm-starter-1.1.1.jar
run the example from ${STORM_HOME} directory:
./bin/storm jar examples/storm-starter/target/storm-starter-1.1.1.jar org.apache.storm.starter.ExclamationTopology
don't add the -local flag since it seems like the ExclamationTopology is only deployed in a LocalCluster if no args are passed. You can check the source code here: ${STORM_HOME}/examples/storm-starter/src/jvm/org/apache/storm/starter/ExclamationTopology.java

Alljoyn Cross compilation: Scons returns of non-existent variable ''alljoyn_jar''

Scons returns with an ERROR: scons: *** Return of non-existent variable ''alljoyn_jar''
the command is:
scons BINDINGS=java OS=openwrt CPU=openwrt VARIANT=debug BUILD_SERVICES_SAMPLES=off POLICYDB=on WS=off
scons: Reading SConscript files ...
Building bindings: java
Building services:
BULLSEYE_BIN not specified
Using OpenSSL crypto
GTEST_DIR not specified skipping common unit test build
BULLSEYE_BIN not specified
GTEST_DIR not specified skipping About Service unit test build
GTEST_DIR not specified skipping alljoyn_core unit test build
scons: *** Return of non-existent variable ''alljoyn_jar''
File "/home/pi/WORKING_DIRECTORY32/alljoyn-15.04.00-src/alljoyn_java/src/SConscript", line 48, in <module>
environment variable:
export CROSS_COMPILE_HOME=/opt/windriver/wrlinux/7.0-intel-quark/sysroots/quark-wrs-linux
export TARGET_PATH=$PATH
export TARGET_CC=gcc
export TARGET_CXX=g++
export TARGET_LINK=gcc
export TARGET_AR=ar
export TARGET_RANLIB=ranlib
export TARGET_CFLAGS="-I$CROSS_COMPILE_HOME/usr/lib/gcc/i586-windriverquark-linux/4.9.1/include -I$CROSS_COMPILE_HOME/usr/local/jdk1.7.0_79/include/"
export TARGET_CPPFLAGS=-I$CROSS_COMPILE_HOME/usr/lib/gcc/i586-windriverquark-linux/4.9.1/include
export TARGET_LDFLAGS=-L$CROSS_COMPILE_HOME/usr/lib
export TARGET_LINKFLAGS=$TARGET_LDFLAGS
export AJ_ROOT=$CROSS_COMPILE_HOME/compiled/alljoyn
export JAVA_HOME=$CROSS_COMPILE_HOME/usr/lib/jvm/java-7-openjdk/jre
Could you help me?
if i'm not wrong, you are trying to build AllJoyn on the RaspberryPI and the Pi is an ARM based CPU, so the first correction u need to make is
CPU=arm
secondly since you are trying to build in Java you need to cross compile
CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf-
for a more detailed procedure of extracting on the RaspberryPi Compiling on the RaspberryPi and you can also have a look the Allseen Alliance Wiki Page

Compilation error - package does not exist - Java

I have the following file structure:
root-folder
--.idea
--folder1-java-console-application (module 1)
----src
------main/java/my/package/App.java
----pom.xml
--folder2-play-framework-2-ui (module 2)
----app
------controllers
--------Application.java
Application.java depends on my.package.App.java. So, I import this package like this:
Application.java:
import my.package.App;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Your new application is ready."));
}
}
Also I added module 1 in dependency list of module 2.
Now, when I start Play-server, I have no any errors. But, when I open URL http://localhost:9000/, I get the error: Compilation error - package my.package.App does not exist.
I get confused. I can compile my code, but I get trouble in runtime. I try play framework in first time in my life. So, probably I don't know some information about this.
The full start project command (from IDEA) is:
"C:\Program Files\Java\jdk1.8.0_11\bin\java" -Dfile.encoding=UTF8 -Djline.terminal=none -Dsbt.log.noformat=true -Dsbt.global.base=C:\Users\Mike\AppData\Local\Temp\sbt-global-plugin3stub -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -classpath C:\Users\Mike\.IntelliJIdea14\config\plugins\Scala\launcher\sbt-launch.jar xsbt.boot.Boot run
(a) check your Play application works without dependencies;
(b) check your Play application has module #1 in class path, when started - see play framework dependencies management;
(c) build module #1 with maven (maven guides + google will help);
(d) check your module #1 jar contains my/package/App.class file.

Why am I getting a NoClassDefFoundError in java?

I managed to successfully compile my code, but I'm not able to execute it. How do I fix this?
scannerTesting is my package and ScannerTesting.java is my main file.
D:\Java>javac Testing\src\scannerTesting\ScannerTesting.java
D:\Java>java Testing\src\scannerTesting\ScannerTesting
Exception in thread "main" java.lang.NoClassDefFoundError: Testing\src\scannerTesting\ScannerTesting <wrong name: scannerTesting/ScannerTesting>
.
.
.
java -cp ./Testing/src scannerTesting.ScannerTesting
When you run java, it looks for matching classes within its classpath. So what these arguments are doing is add your source folder to the classpath using -cp, and specify that the class that should be run is scannerTesting.ScannerTesting.
For more information, check out java cli tool documentation at Oracle
scannerTesting is your package name,right?
If so, I suggest you run command "java" under the workspace D:\Java\Testing\src
java scannerTesting.ScannerTest

Categories