0

To begin with, I'm not entirely sure this is the correct question. Basically, my end goal is to produce a program that can manipulate a set of .docx files to have small changes to each of them. It seemed to me that docx4j was the best way to complete this goal. However, I've never used a library outside of the provided one. I began by attempting to decipher all the information provided in the manual, and it began by telling me I need SLF4J in order to let me use docx4j.

The SLF4J manual told me to "add the file slf4j-api-1.7.7.jar to your class path." as well as the file "slf4j-simple-1.7.7.jar"

I proceeded to go to System > Advanced System Settings > Environment Variables and I found "Path" under System variables. It seemed to me that this was the correct "class path", so I added to the end of it C:\Users\diego_000\Desktop\slf4j-1.7.7\slf4j-api-1.7.7.jar;C:\Users\diego_000\Desktop\slf4j-1.7.7\slf4j-simple-1.7.7.jar; This seemed to be what the manual told me to do and I was confident of the Hello World program (provided by their website) running successfully.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HelloWorld {
  public static void main(String[] args) {
    Logger logger = LoggerFactory.getLogger(HelloWorld.class);
    logger.info("Hello World");
  }
}

On compilation, I'm thrown the following errors:

Compilation completed.  The following files were not compiled:
4 errors found:
File: C:\Users\diego_000\Desktop\Program\HelloWorld.java  [line: 1]
Error: package org.slf4j does not exist
File: C:\Users\diego_000\Desktop\Program\HelloWorld.java  [line: 2]
Error: package org.slf4j does not exist
File: C:\Users\diego_000\Desktop\Program\HelloWorld.java  [line: 6]
Error: cannot find symbol
  symbol:   class Logger
  location: class HelloWorld
File: C:\Users\diego_000\Desktop\Program\HelloWorld.java  [line: 6]
Error: cannot find symbol
  symbol:   variable LoggerFactory
  location: class HelloWorld

From this, I gather I've done something wrong. I'm fairly certain I know the pseudo logic behind the program I want to write, but I'm not really sure how to get to the point of writing it. I haven't done any research past the point I'm at, but if someone could go beyond just this question and walk me through the steps of getting to the writing code point, I would very much appreciate it.

Thanks!

Ben
  • 7,548
  • 31
  • 45
Ryan
  • 47
  • 1
  • 1
  • 6

2 Answers2

0

sorry, the PATH is for executables... Check out the CLASSPATH section at the end.

http://docs.oracle.com/javase/tutorial/essential/environment/paths.html

jroot
  • 320
  • 1
  • 9
  • Okay, so I went to the environment variables section and added a "CLASSPATH" variable, with the two paths above that I mentioned and got the same errors, what am i missing? – Ryan Oct 26 '14 at 06:18
  • Easiest to use an IDE and Maven. Try http://www.docx4java.org/blog/2011/10/hello-maven-central/ – JasonPlutext Oct 26 '14 at 06:41
  • You're not running `javac` in Cygwin or similar are you? Be aware that Windows uses semi-colons as path separators but UN*X-style environments use colons. – Ben Oct 27 '14 at 14:32
0

See this question, the top answer shows how to set jar files as part of the classpath. for javac (compiler version) the format is similar

java -cp "Test.jar;lib/*" my.package.MainClass

javac -classpath .:/home/avh/classes:/usr/local/java/classes ...
javac -cp .:/home/avh/classes:/usr/local/java/classes ...

Please note that on linux/unix the path separator is : , on windows the quoted string and ; is usually the way to go.

Community
  • 1
  • 1
Joeblade
  • 1,735
  • 14
  • 22