Running batch file from command prompt getting error - java

Hi I have a batch file which basically updates some table in the database by running the job.
Here is a batch file code:
set CLASSPATH=C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\selenium-server-standalone-2.32.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jsoup-1.7.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xstream-1.1.3.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\XmlSchema-1.4.7.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-http-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\log4j-1.2.17.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\mysql-connector-java-5.1.13.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\httpclient-4.1.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\httpcore-4.1.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\commons-httpclient-3.0.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\gson-1.6.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\lucene-core-3.3.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-adb-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axiom-api-1.2.12.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-kernel-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\wsdl4j-1.6.2.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\XmlSchema-1.4.7.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axiom-impl-1.2.12.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\neethi-3.0.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\freemarker.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\smtp.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-local-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-http-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\mailapi.jar;
C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-context-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-core-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-beans-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-asm-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-aop-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-tx-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\aopalliance-1.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-expression-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-orm-3.1.1.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\transactions-jdbc-3.8.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\transactions-osgi-3.8.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\hibernate-3.2.1.ga.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\hibernate-annotations-3.2.0.ga.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jboss-transaction-api_1.1_spec-1.0.0.Final.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\spring-jdbc-3.1.0.RELEASE.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\dom4j-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\transactions-hibernate3-3.8.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\gdata-core-1.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xstream-1.1.3.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\commons-lang-2.3.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xmlunit-1.5.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\log4j-1.2.17.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\axis2-transport-http-1.6.1.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\mailapi.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\antlr-2.7.7.jar;
C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;
java -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m com.myProject.batch.PropertyRatesUpdaterBatchJob
I am trying to run the batch file from command prompt but I am getting error like
C:\ProjectWorkSpace\myProject\tools>C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;
'C:\ProjectWorkSpace\myProject\web\WEB-INF\classes' is not recognized as an internal or external command,
operable program or batch file.
and the second error at the end I am getting as
Exception in thread "main" java.lang.NoClassDefFoundError: com/myProject/batch /PropertyRatesUpdaterBatchJob
Caused by: java.lang.ClassNotFoundException: com.myProject.batch.PropertyRatesUpdaterBatchJob
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
and I am not able to run the batch file.
Anybody can help me to how to run the same and what this error mean.
Hi here is my new batch file:
set CLASSPATH=C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\selenium-server-standalone-2.32.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\jsoup-1.7.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\xstream-1.1.3.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\XmlSchema-1.4.7.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-http-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\log4j-1.2.17.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\mysql-connector-java-5.1.13.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\httpclient-4.1.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\httpcore-4.1.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\commons-httpclient-3.0.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\gson-1.6.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\lucene-core-3.3.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-adb-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axiom-api-1.2.12.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-kernel-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\wsdl4j-1.6.2.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\XmlSchema-1.4.7.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axiom-impl-1.2.12.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\neethi-3.0.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\freemarker.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\smtp.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-local-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-http-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\mailapi.jar;C:\ProjectWorkSpace\zaranga\WEB-INF\classes;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-context-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-core-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-beans-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-asm-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-aop-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-tx-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\aopalliance-1.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-expression-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-orm-3.1.1.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\transactions-jdbc-3.8.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\transactions-osgi-3.8.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\hibernate-3.2.1.ga.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\hibernate-annotations-3.2.0.ga.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\jboss-transaction-api_1.1_spec-1.0.0.Final.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\spring-jdbc-3.1.0.RELEASE.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\dom4j-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\transactions-hibernate3-3.8.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\gdata-core-1.0.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\xstream-1.1.3.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\commons-lang-2.3.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\xmlunit-1.5.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\log4j-1.2.17.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\axis2-transport-http-1.6.1.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\mailapi.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\lib\antlr-2.7.7.jar;C:\ProjectWorkSpace\zaranga\build\zaranga\WEB-INF\classes
java -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m com.zaranga.batch.PropertyRatesUpdaterBatchJob
Now I am getting a new error log4j as
Error is :
No org.slf4j.impl.StaticLoggerBinder found in ClassPath, trying with log4j...
Any help will be greatly appriciated.

I assume with
set CLASSPATH=C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\selenium-server-standalone-2.32.0.jar;
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jsoup-1.7.2.jar;
You wanted to also add jsoup-1.7.2.jar; to the CLASSPATH variable, but you can't just extend a command over multiple lines like that.
If you want to write this on multiple lines, each line (except for the last one of course) must end with the so called "line continuation character" which tells Windows that the command (in your case the SET) isn't finished yet, even though the line is. This character is ^ in Windows (comparable to the \ in Linux/Unix shell scripts)
So what you need is:
set CLASSPATH=C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\selenium-server-standalone-2.32.0.jar; ^
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\jsoup-1.7.2.jar; ^
C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\xstream-1.1.3.jar; ^
.... ^
.... ^
C:\ProjectWorkSpace\myProject\web\WEB-INF\classes;
java -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=128m com.myProject.batch.PropertyRatesUpdaterBatchJob
(btw: you have C:\ProjectWorkSpace\myProject\web\WEB-INF\classes twice in your list)
You must make sure that there is no whitespace whatsoever after the ^ otherwise this will not work.
Btw: you shouldn't be using the CLASSPATH variable anymore. It's better to explicitly define a classpath using the -cp (or -classpath parameter for the java command).
In recent (up-to-date) versions of Java for Windows you don't need to specify each element in the classpath variable.
Quote from http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html
As a special convenience, a class path element that contains a base name of * is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR
So you can get rid of all the lines and just use:
java -cp C:\ProjectWorkSpace\myProject\build\myProject\WEB-INF\lib\*;C:\ProjectWorkSpace\myProject\web\WEB-INF\classes com.myProject.batch.PropertyRatesUpdaterBatchJob

Related

Apache Jena: Error: "java.lang.NoClassDefFoundError: org/apache/jena/riot/RDFDataMgr"

Problem explanation
I have recently been trying to use Apache Jena with Java (rather than on the command line). I wrote a simple script to convert read and write differetn RDF format types, as so
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.query.Dataset;
import org.apache.jena.riot.Lang;
public class Go_NT
{
public static void main(String[] args)
{
Dataset dataset = RDFDataMgr.loadDataset("triail.nq");
RDFDataMgr.write(System.out, dataset, Lang.NTRIPLES);
}
}
triail.nq is a test nquads file containing 81 quads.
I invoked it as so:
javac -cp "/mnt/e/Tráchtas/apache-jena-3.17.0/lib/*" Go_NT.java
java Go_NT
It compiles without error, but when I run it, it returns an error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/jena/riot/RDFDataMgr
at Go_NT.main(Go_NT.java:9)
Caused by: java.lang.ClassNotFoundException: org.apache.jena.riot.RDFDataMgr
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
What I have tried
I have looked around and seen that this error occurs almost always because a necessary .jar file is not included, so a class referenced by the code cannot be loaded. The solution to these other issues was to include all of /apache-jena-3.17.0/lib/* . Oddly enough, that has not worked for me--I do include all of the contents of lib/ in my classpath, but I am still seeing the error.
System notes
I am running Jena 3.17.0, using the default Linux binaries available here (https://jena.apache.org/download/index.cgi). I have not added or removed any other Jena modules.
I am running this in the Windows Subsystem for Linux (version 2) with Ubuntu 20.04.
If any of you have any insight into what could be causing this, I would greatly appreciate it!
Based on the comment by vvs, the link https://howtodoinjava.com/java-examples/set-classpath-command-line/ helped out a lot. There were 2 issues: I needed to include the classpath in the java command, not just javac. I also needed to include the current directory where the output of javac would be.
I fixed this by setting the CLASSPATH variable, and then adding all the needed directories to that. (You could also do this by adding the classpath into the -cp argument). Note that the : separates different directories.
In short, here is what I did:
export CLASSPATH=/mnt/e/Tráchtas/apache-jena-3.17.0/lib/*:.
javac Go_NT.java
java Go_NT
Note that you need to re-assign CLASSPATH each time you open a new terminal.

Getting No such File or Directory Exception on Ubuntu when trying compile a java project from java.lang.Process

Recently, I have switched to Ubuntu v20.04 from Windows 10 Pro v2004 because of performance purposes. When, I was on Windows I can freely compile a java project from another java program by writing:
String pathToCompiler = "\"C:/Program Files/Java/jdk-14/bin/javac\"";
Process compileProcess = Runtime.getRuntime().exec(pathToCompiler+" -d bin #.sources", null, new File("ProjectPath"))
Where the sources file is a file containing the list of classes of the project
The code above works successfully on Windows 10.
But On Linux(Ubuntu):
if I substitute the value of variable pathToCompiler as
pathToCompiler = "\"/usr/lib/jvm/java-11-openjdk-amd64/bin/javac\""
the below exception is raised up and the program executing the command exits:
"/usr/lib/jvm/java-11-openjdk-amd64/bin/javac" -d bin #.sources
java.io.IOException: Cannot run program ""/usr/lib/jvm/java-11-openjdk-amd64/bin/javac"" (in directory "/home/arham/Documents/Omega Projects/Project0"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at java.base/java.lang.Runtime.exec(Runtime.java:592)
at java.base/java.lang.Runtime.exec(Runtime.java:416)
at ide.utils.systems.BuildView.lambda$3(BuildView.java:267)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
The problem is that the file actually exists but it says No Such File or Directory
Actually, The program which is compiling the project is a Java IDE that I am creatiing.
Someone please tell if he/she knows how to fix this bug
The Runtime.exec method has several problems that make it difficult to use, and this is one of them. Use the newer ProcessBuilder class instead.
String pathToCompiler = "C:/Program Files/Java/jdk-14/bin/javac";
Process compileProcess = new ProcessBuilder(pathToCompiler, "-d", "bin", "#.sources")
.directory(new File("ProjectPath"))
.start();
The differences are:
Remove the extra quotes from around the path to the executable. If quoting is needed, the system takes care of it.
Pass the each command line arguments as a separate string. This way you don't have to worry about quoting.
Update the path to the following:
String pathToCompiler = "/usr/lib/jvm/java-11-openjdk-amd64/bin/javac/";

How to run simple jdbc connection program through cmd

Below approach I tried to run and compil
for compile:
javac -cp "C:\Program Files\Java\jdk1.7.0_45\bin;D:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc.jar" OracleTest.java
for execution:
java -cp "C:\Program Files\Java\jdk1.7.0_45\bin;D:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc.jar;." OracleTest
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
The JDBC drivers from oracle usually include a (Java) version number in the name like ojdbc14.jar or ojdbc7.jar. I do not have Oracle installed here, so please check the correct name in your directory D:\oracle\product\10.2.0\db_1\jdbc\lib\.
You can test my DBTester program I wrote a long time ago from here. After downloading the jar - eventually you need to rename DBTester.jar.zip to DBTester.jar - just execute it in the directory you saved the jar:
java -cp "DBTester.jar;D:\oracle\product\10.2.0\db_1\jdb‌​c\lib\ojdbc7.jar" cfh.dbtester.Main -d
(assuming the ojdbc7.jar is the driver file and using Java 7 or later)
This should print a summary for some drivers, including the Oracle one, like
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
...
java.lang.ClassNotFoundException: com.ingres.jdbc.IngresDriver
oracle.jdbc.driver.OracleDriver OK
the last line is telling me that I have the OracleDriver available.
Note: DBTester.jar creates a file named dbtester.log with its results.
Can you try with this?
"%JAVA_HOME%\bin\java.exe" -cp "%~dp0\ojdbc.jar" OracleTest.java
Important thing to note here is to have the JAR file at the same location as of your JAVA class that you want to compile/execute and accordingly change the command.
Hope this helps!

Java Classpath error-cannot find my class

I am trying to use randoop(automatic test generator for Java) and randoop cannot find my class:
eliezer#ubuntu:~/Desktop$ java -ea -classpath \
randoop.1.3.2.jar:home/eliezer/myclasses \
randoop.main.Main gentests \
--testclass=/home/eliezer/Desktop/myclasses/ArrayListError
policy = sun.security.provider.PolicyFile#85af80
Throwable thrown while handling command:java.lang.Error:\
classForName(/home/eliezer/Desktop/myclasses/ArrayListError)
java.lang.Error: classForName(/home/eliezer/Desktop/myclasses/ArrayListError)
at randoop.util.Reflection.classForName(Reflection.java:206)
at randoop.util.Reflection.loadClassesFromList(Reflection.java:386)
at randoop.main.GenInputsAbstract.findClassesFromArgs(GenInputsAbstract.java:507)
at randoop.main.GenTests.handle(GenTests.java:184)
at randoop.main.Main.nonStaticMain(Main.java:80)
at randoop.main.Main.main(Main.java:42)
Caused by: java.lang.ClassNotFoundException: \
/home/eliezer/Desktop/myclasses/ArrayListError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at randoop.util.Reflection.classForName(Reflection.java:198)
... 5 more
Randoop failed.
Last sequence under execution:null
My class is called ArrayListError.java and is found in /home/eliezer/Desktop/myclasses.
The randoop docs are found at: https://randoop.github.io/randoop/manual/index.html.
I am sure it is something really trivial but I'm inexperienced with these things.
You need to set your classpath such that, jvm should be able to locate all your resources like classes, files, jars etc.
In your case, ArrayListError is placed under directory /home/eliezer/Desktop/myclasses. You need to place this in your classpath.
Once you point your classpath to mentioned directory, You need to pass the class name to --testclass=ArrayListError.
java -ea -classpath randoop.1.3.2.jar:/home/eliezer/Desktop/myclasses randoop.main.Main gentests --testclass=ArrayListError
should fix your problem. I suggest you to search on setting classpath and read on.
This is wrong
my class is called ArrayListError.java and is found in
/home/eliezer/Desktop/myclasses.
Your ArrayListError.java is the source code, but java virtual machine needs a compiled class in its classpath.
EDIT:
Since you said that you have the .class file also, then your problem can be solved in two ways
a. No package
Run the command (take care of the --testclas, it is not directory, it should be the class)
java -ea -classpath randoop.1.3.2.jar:/home/eliezer/myclasses
randoop.main.Main gentests --testclass=ArrayListError
b. Class in a package
If your ArrayListError does have package com.test; make a directory /com/test in your myclasses directory and run the command below
java -ea -classpath
randoop.1.3.2.jar:/home/eliezer/myclasses/com/test/ randoop.main.Main
gentests --testclass=com.test.ArrayListError
Check your classpath on the command line;
I see home/eliezer/myclasses, without the leading /.

tdbloader on Cygwin: Gettging FileNotFoundException: d:\cygdrive\d\....\node2id.idn

I am completely new to Jena/TDB. All I want to do is to load data from some sample rdf, N3 etc file using tdb scripts or through java api.
I am tried to use tbdloader on Cygwin to load data (tdb-0.9.0, on Windows XP with IBM Java 1.6). Following are the command that I ran:
$ export TDBROOT=/cygdrive/d/Project/Store_DB/jena-tdb-0.9.0-incubating
$ export PATH=$TDBROOT/bin:$PATH
I also changed classpath for java in the tdbloader script as mentioned at tdbloader on Cygwin: java.lang.NoClassDefFoundError :
exec java $JVM_ARGS $SOCKS -cp "PATH_OF_JAR_FILES" "tdb.$TDB_CMD" $TDB_SPEC "$#"
So when I run $ tdbloader --help it shows the help correctly.
But when I run
$ tdbloader --loc /cygdrive/d/Project/Store_DB/data1
OR
$ tdbloader --loc /cygdrive/d/Project/Store_DB/data1 test.rdf
I am getting following exception:
com.hp.hpl.jena.tdb.base.file.FileException: Failed to open: d:\cygdrive\d\Project\Store_DB\data1\node2id.idn (mode=rw)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.open$(ChannelManager.java:83)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.openref$(ChannelManager.java:58)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.acquire(ChannelManager.java:47)
at com.hp.hpl.jena.tdb.base.file.FileBase.<init>(FileBase.java:57)
at com.hp.hpl.jena.tdb.base.file.FileBase.<init>(FileBase.java:46)
at com.hp.hpl.jena.tdb.base.file.FileBase.create(FileBase.java:41)
at com.hp.hpl.jena.tdb.base.file.BlockAccessBase.<init>(BlockAccessBase.java:46)
at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.createStdFile(BlockMgrFactory.java:98)
at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.createFile(BlockMgrFactory.java:82)
at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.create(BlockMgrFactory.java:58)
at com.hp.hpl.jena.tdb.setup.Builder$BlockMgrBuilderStd.buildBlockMgr(Builder.java:196)
at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.createBPTree(Builder.java:165)
at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.buildRangeIndex(Builder.java:134)
at com.hp.hpl.jena.tdb.setup.Builder$IndexBuilderStd.buildIndex(Builder.java:112)
at com.hp.hpl.jena.tdb.setup.Builder$NodeTableBuilderStd.buildNodeTable(Builder.java:85)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd$NodeTableBuilderRecorder.buildNodeTable(DatasetBuilderStd.java:389)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeNodeTable(DatasetBuilderStd.java:300)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd._build(DatasetBuilderStd.java:167)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:157)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:70)
at com.hp.hpl.jena.tdb.StoreConnection.make(StoreConnection.java:132)
at com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction.<init>(DatasetGraphTransaction.java:46)
at com.hp.hpl.jena.tdb.sys.TDBMakerTxn._create(TDBMakerTxn.java:50)
at com.hp.hpl.jena.tdb.sys.TDBMakerTxn.createDatasetGraph(TDBMakerTxn.java:38)
at com.hp.hpl.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.java:166)
at com.hp.hpl.jena.tdb.TDBFactory.createDatasetGraph(TDBFactory.java:74)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:53)
at tdb.cmdline.ModTDBDataset.createDataset(ModTDBDataset.java:95)
at arq.cmdline.ModDataset.getDataset(ModDataset.java:34)
at tdb.cmdline.CmdTDB.getDataset(CmdTDB.java:137)
at tdb.cmdline.CmdTDB.getDatasetGraph(CmdTDB.java:126)
at tdb.cmdline.CmdTDB.getDatasetGraphTDB(CmdTDB.java:131)
at tdb.tdbloader.loadQuads(tdbloader.java:163)
at tdb.tdbloader.exec(tdbloader.java:122)
at arq.cmdline.CmdMain.mainMethod(CmdMain.java:97)
at arq.cmdline.CmdMain.mainRun(CmdMain.java:59)
at arq.cmdline.CmdMain.mainRun(CmdMain.java:46)
at tdb.tdbloader.main(tdbloader.java:53)
Caused by: java.io.FileNotFoundException: d:\cygdrive\d\Project\Store_DB\data1\node2id.idn (The system cannot find the path specified.)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:222)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:107)
at com.hp.hpl.jena.tdb.base.file.ChannelManager.open$(ChannelManager.java:80)
... 37 more
I am not sure what node2id.idn file is and why is it expecting it?
The file node2id.idn is one of TDB's internal index files. It's not something that you have to create or manage for yourself. I've just tried tdbloader on cygwin myself, it it worked OK for me. I can think of two basic possibilities:
your disk is full
the TDB index is corrupted
If this is the first file you are loading into an otherwise emtpy TDB, the second possibility is unlikely. If you are loading into a non-empty TDB, try deleting the TDB image and starting again. Note that TDB by itself does not manage concurrent writes: if you have more than one process writing to a single TDB image, you must handle locking at the application level, or use TDB's transactions.
The final possibility, of course, is that your disk is flaky. You might want to try your code on another machine.
If none of these suggestions help, please send a complete minimal test case to the Jena users list.

Categories

Resources