This worked!

I ran a slightly tweaked version of Jean-Marcs script:

unset JARS
for f in $JENA_HOME/lib/*.jar
do
  JARS=$JARS:$f
  export JARS
done

I then added $JARS to my CLASSPATH and everything works great!

Thanks all!




On Tue, Apr 24, 2018 at 6:58 AM, Jean-Marc Vanel <[email protected]>
wrote:

> Dear Cumulative,
> here is the script I use in Linux to build the classpath :
>
> unset JARS
> for f in lib/*.jar
> do
>   JARS=$JARS:$f
> done
>
> which gives:
> echo $JARS
> :lib/collection-0.7.jar:lib/commons-cli-1.4.jar:lib/
> commons-codec-1.11.jar:lib/commons-csv-1.5.jar:lib/commons-io-2.6.jar:lib/
> commons-lang3-3.4.jar:lib/httpclient-4.5.3.jar:lib/
> httpclient-cache-4.5.3.jar:lib/httpcore-4.4.6.jar:lib/
> jackson-annotations-2.9.0.jar:lib/jackson-core-2.9.0.jar:
> lib/jackson-databind-2.9.0.jar:lib/jcl-over-slf4j-1.7.25.
> jar:lib/jena-arq-3.6.0.jar:lib/jena-base-3.6.0.jar:lib/
> jena-cmds-3.6.0.jar:lib/jena-core-3.6.0.jar:lib/jena-dboe-
> base-3.6.0.jar:lib/jena-dboe-index-3.6.0.jar:lib/jena-dboe-
> transaction-3.6.0.jar:lib/jena-dboe-trans-data-3.6.0.
> jar:lib/jena-iri-3.6.0.jar:lib/jena-rdfconnection-3.6.0.
> jar:lib/jena-shaded-guava-3.6.0.jar:lib/jena-tdb2-3.6.0.jar:
> lib/jena-tdb-3.6.0.jar:lib/jsonld-java-0.11.1.jar:lib/
> libthrift-0.10.0.jar:lib/log4j-1.2.17.jar:lib/slf4j-
> api-1.7.25.jar:lib/slf4j-log4j12-1.7.25.jar:lib/
> xercesImpl-2.11.0.jar:lib/xml-apis-1.4.01.jar
>
> Then I can compile or run :
>
> java -cp $JARS riotcmd.riot --help
> riot [--time] [--check|--noCheck] [--sink] [--base=IRI] [--out=FORMAT]
> [--compress] file ...
>   Parser control
>       --sink                 Parse but throw away output
>       --syntax=NAME          Set syntax (otherwise syntax guessed from file
> extension)
>       --base=URI             Set the base URI (does not apply to N-triples
> and N-Quads)
>       --check                Addition checking of RDF terms
>       --strict               Run with in strict mode
>       --validate             Same as --sink --check --strict
>       --rdfs=file            Apply some RDFS inference using the vocabulary
> in the file
>       --nocheck              Turn off checking of RDF terms
>       --stop                 Stop parsing on encountering a bad RDF term
>       --stop-warnings        Stop parsing on encountering a warning
> ... etc ....
>
> Or you can do this to have the absolute files in CLASSPATH:
>
> unset JARS
> for f in $JENA_HOME/lib/*.jar
> do
>   JARS=$JARS:$f
> done
>
>
> 2018-04-24 15:37 GMT+02:00 Cumulative Knowledge <[email protected]
> >:
>
> > Hi Lorenz,
> >
> > Thank you for the support - I'm still getting oriented.
> >
> > Based on Andys feedback I added the environmental variable for classpath
> > with '...\lib\*' to include all the jars in the directory. I've also
> tried
> > running it like you mentioned:
> >
> > javac -cp <THE_CLASSPATH_TO_JENA_LIBS_HERE>   Tutorial01.java
> >
> > I still get the same errors. Maybe I'm misunderstanding the directories,
> > file paths, and files I need to configure for Jena on a Mac. This could
> be
> > a lower level of information than what most first time Jena users need.
> > Currently all the paths point to the bin and lib directory in the main
> > folder. The jar files in the lib directory all have names which include
> > version numbers. Nothing is pointed to the bat directory. I'm running the
> > file from terminal in the same directory as the file.
> >
> > Does anything seem weird with this set up? Do I need to rename files in
> the
> > lib directory? Should I point to the bat directory or execute those
> files?
> >
> > Thank you for your patience!
> > Louis
> >
> >
> > More info below.
> >
> > In Mac I have set JENA_HOME and JENAROOT set to the main directory for
> > jena:
> >
> > /Users/username/Documents/jena/apachejena370
> >
> > I don't know if it makes a difference, but I renamed the directory from:
> >
> > /Users/username/Documents/jena/apache-jena-3.7.0
> >
> >
> > When adding JENA_HOME to the PATH I included did so as:
> >
> > export PATH=$PATH:$JENA_HOME/bin
> >
> >
> > When adding the classpath I did so with:
> >
> > export CLASSPATH=$CLASSPATH:$JENA_HOME/bin/\*
> >
> >
> >
> >
> >
> > On Mon, Apr 23, 2018 at 11:59 PM, Lorenz Buehmann
> <[email protected]
> > leipzig.de> wrote:
> >
> > > Andy already told you in one of the previous mails that you have to add
> > > the classpath to the Java compiler:
> > >
> > > javac -cp <THE_CLASSPATH_TO_JENA_LIBS_HERE>   Tutorial01.java
> > >
> > >
> > > On 24.04.2018 02:31, Cumulative Knowledge wrote:
> > > > Hi all,
> > > >
> > > > I'm having an issue getting Jena up and running on my Mac. I think I
> > have
> > > > everything installed right, but I must be missing something. Details
> > > below
> > > > (and on StackOverflow
> > > > <https://stackoverflow.com/questions/49991720/apache-jena-
> > > installation-issues-with-jenaroot-on-mac>
> > > > ).
> > > >
> > > > Any ideas appreciated.
> > > >
> > > > Thanks!
> > > >
> > > > $ sparql --version
> > > > Jena: VERSION: 3.7.0 Jena: BUILD_DATE: 2018-04-05T11:04:59+0000 ARQ:
> > > > VERSION: 3.7.0 ARQ: BUILD_DATE: 2018-04-05T11:04:59+0000 RIOT:
> VERSION:
> > > > 3.7.0 RIOT: BUILD_DATE: 2018-04-05T11:04:59+0000
> > > >
> > > > Here are my current environmental variable settings:
> > > >
> > > > $ echo $JAVA_HOME
> > > > /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
> > > >
> > > > $JENA_HOME
> > > > /Users/username/Documents/jena/apachejena370
> > > >
> > > > echo $JENAROOT
> > > > /Users/username/Documents/jena/apachejena370
> > > >
> > > > $ echo $CLASSPATH
> > > > /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/
> > > Home/bin:/Users/username/Documents/jena/apachejena370/lib/*
> > > >
> > > > When I run the code:
> > > >
> > > > $ sudo java Tutorial01
> > > >
> > > > Exception in thread "main" java.lang.NoClassDefFoundError:
> > > > org/apache/jena/rdf/model/ModelFactory
> > > >     at Tutorial01.main(Tutorial01.java:34)
> > > > Caused by: java.lang.ClassNotFoundException:
> > > > org.apache.jena.rdf.model.ModelFactory
> > > >     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> > > >     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> > > >     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> > > >     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> > > >     ... 1 more
> > > >
> > > > I've also somehow broken something because javac is no longer
> working:
> > $
> > > > sudo javac Tutorial01.java
> > > >
> > > > Tutorial01.java:21: error: package org.apache.jena.rdf.model does not
> > > exist
> > > > import org.apache.jena.rdf.model.*;
> > > > ^
> > > > Tutorial01.java:22: error: package org.apache.jena.vocabulary does
> not
> > > exist
> > > > import org.apache.jena.vocabulary.*;
> > > > ^
> > > > Tutorial01.java:34: error: cannot find symbol
> > > >         Model model = ModelFactory.createDefaultModel();
> > > >         ^
> > > >   symbol:   class Model
> > > >   location: class Tutorial01
> > > > Tutorial01.java:34: error: cannot find symbol
> > > >         Model model = ModelFactory.createDefaultModel();
> > > >                       ^
> > > >   symbol:   variable ModelFactory
> > > >   location: class Tutorial01
> > > > Tutorial01.java:37: error: cannot find symbol
> > > >        Resource johnSmith = model.createResource(personURI);
> > > >        ^
> > > >   symbol:   class Resource
> > > >   location: class Tutorial01
> > > > Tutorial01.java:40: error: cannot find symbol
> > > >       johnSmith.addProperty(VCARD.FN, fullName);
> > > >                             ^
> > > >   symbol:   variable VCARD
> > > >   location: class Tutorial01
> > > > 6 errors
> > > >
> > >
> > >
> >
>
>
>
> --
> Jean-Marc Vanel
> http://www.semantic-forms.cc:9111/display?displayuri=http:/
> /jmvanel.free.fr/jmv.rdf%23me#subject
> <http://www.semantic-forms.cc:9111/display?displayuri=http:/
> /jmvanel.free.fr/jmv.rdf%23me>
> Déductions SARL - Consulting, services, training,
> Rule-based programming, Semantic Web
> +33 (0)6 89 16 29 52
> Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui
>

Reply via email to