I'm not a Java programmer, but my boss tasked me with getting someone else's code running. Sorry for the noob question.
I have the code running perfectly via `Eclipse` on my OSX system. However, the need is for it to be running from the command line.
I'm trying to run the code on my OSX box that was compiled by eclipse when I ran it there.
I've set up the environment as best I can. But when I attempt to run the *.class files, I get...
init mikes$ pwd
/Users/(snip)/Eclipseworks
pace/Anony
mize/bin/i
nit
init mikes$ java Init.class
Error: Could not find or load main class Init.class
init mikes$ java ./Init.class
Error: Could not find or load main class ..Init.class
`main` is definitely in Init.class
**Init.java**
package init;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
import java.net.*;
import anonymizer.Anonymizer;
public class Init {
public static String STOPWORDS;
(...snip...)
static {
// Define location of resource files
STOPWORDS = "misc" + File.separator + "stopwordlist_de.txt";
(...snip...)
}
public static void main(String[] args) throws IOException {
if (args.length !=1) {
System.err.println("Usage:
Anonymize <path to docx files>");
System.exit(1);
}
try (Stream<Path> paths = Files.walk(Paths.get(args[
0]))) {
paths.skip(1).filter(file -> file.toString().endsWith("
docx")).fo
rEach(file
-> {
Anonymizer ano;
try {
// Creates an instance of the Anonymizer class and executes the pipeline
ano = new Anonymizer(file.toString()
, file.toString()+".anon");
ano.anonymizeAdmissionNote
s();
} catch (Exception e) {
e.printStackTrace();
}
});
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("De-Ide
ntificatio
n finished.");
}
}
** Directory Structure **
Anonymize mikes$ pwd
/Users/(snip)/Eclipseworks
pace/Anony
mize/
Anonymize mikes$ find . | grep -v <non_pertinent_stuff>
.
./misc
./misc/suffixes_towns.txt
./misc/regex_mappings_surn
ames.txt
./misc/regex_mappings_inte
rnational_
firstnames
.txt
./misc/suffixes_streets.tx
t
./misc/tokenizer.jar
./misc/stopwordlist_de.txt
./misc/regex_mappings_stre
ets_with_n
umbers_and
_abr.txt
./misc/header_tokens.txt
./misc/regex_mappings_gene
ral.txt
./misc/regex_mappings_town
s_and_vill
ages.txt
./bin
./bin/init
./bin/init/Init.class
./bin/anonymizer
./bin/anonymizer/DocxReade
r.class
./bin/anonymizer/Anonymize
r.class
./bin/anonymizer/NamedEnti
tyRecogniz
er.class
./.classpath
./lib
./lib/xmlbeans-2.6.0.jar
./lib/poi-3.17.jar
./lib/poi-ooxml-schemas-3.
17.jar
./lib/poi-ooxml-3.17.jar
./lib/stanford-german-core
nlp-2017-0
6-09-model
s.jar
./lib/stanford-corenlp-3.8
.0.jar
** This is how I tried to setup the environment, and run the code. **
init mikes$ export CLASSPATH="${CLASSPATH}:.:
\
/Users/(snip)/Eclipseworks
pace/Anony
mize/bin/:
\
/Users/(snip)/Eclipseworks
pace/Anony
mize/bin/i
nit/:\
/Users/(snip)/Eclipseworks
pace/Anony
mize/bin/a
nonymizer/
:\
/Users/(snip)/Eclipseworks
pace/Anony
mize/lib/:
\
/Users/(snip)/Eclipseworks
pace/Anony
mize/misc/
"
init mikes$ export PATH="${PATH}:${CLASSPATH}
"
init mikes$ pwd
/Users/(snip)/Eclipseworks
pace/Anony
mize/bin/i
nit
init mikes$ java Init.class
Error: Could not find or load main class Init.class
init mikes$ java ./Init.class
Error: Could not find or load main class ..Init.class
init mikes$ java init.Init
Error: Could not find or load main class java
**I'm not finding my mistake. What do I need to change/do, to get this code running from the command line?**
[1]:
https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean