# Help with HTM.Java examples

**URL:** <https://discourse.numenta.org/t/help-with-htm-java-examples/469>\
**Category:** HTM.Java\
**Created:** [May 21, 2016, 12:12am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469 "2016-05-21T00:12:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Addonis](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/addonis/32/342_2.png) [@Addonis](https://discourse.numenta.org/u/Addonis)\
**Post date:** [May 21, 2016, 12:12am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/1 "2016-05-21T00:12:05Z")

</div>

I should hypothetically already have everything for the Linux installation…I’ve never used Docker and from what I’ve heard/seen, it’s pretty difficult to use for the first time.  
What do the HTM.java examples do? Where can I find them?

---

<div class="post-metadata">

**Author:** ![cogmission](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/cogmission/32/11_2.png) [@cogmission](https://discourse.numenta.org/u/cogmission)\
**Post date:** [May 21, 2016, 12:56am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/2 "2016-05-21T00:56:56Z")

</div>

> [@Problems using a Nupic example (Hotgym)](https://discourse.numenta.org/t/problems-using-a-nupic-example-hotgym/467/3):
>
> What do the HTM.java examples do? Where can I find them?

There are 4 or 5 demos in the HTM.java-examples repository. You can find them and the instructions for using them at: [https://github.com/numenta/htm.java-examples](https://github.com/numenta/htm.java-examples)

Also, I would try and get in contact with @rhyolight to ask about running the Docker file for NuPIC and also get your installation going if you are a Python or C++ guy. Otherwise, HTM.java is the same code same everything (except no swarming for now and no OPF framework - there is however a Network API for its use and a wiki on how to use it.)

HTM.java is the equivalent of NuPIC except that its playing “catch up” with NuPIC for certain functionality and is community ported from NuPIC with all the same tests etc. to guarantee its compatibility.

---

<div class="post-metadata">

**Author:** ![Addonis](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/addonis/32/342_2.png) [@Addonis](https://discourse.numenta.org/u/Addonis)\
**Post date:** [May 21, 2016, 2:24am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/3 "2016-05-21T02:24:22Z")

</div>

I tried running the Hotgym demo and got an error. My friend tried running it to and got basically the same error.

```auto
java.io.FileNotFoundException: C:\Users\Ayumi\Desktop\Nupic,%20mysql,%20etc\htm.java-examples-master\src\main\java\org\numenta\nupic\examples\napi\hotgym\NAPI-Hotgym-Demo-v0.6.8-alpha.jar (The system cannot find the path specified)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at org.numenta.nupic.network.sensor.FileSensor.getJarEntryStream(FileSensor.java:148)
        at org.numenta.nupic.network.sensor.FileSensor.<init>(FileSensor.java:78)
        at org.numenta.nupic.network.sensor.FileSensor.create(FileSensor.java:110)
        at org.numenta.nupic.network.sensor.Sensor.create(Sensor.java:75)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.createBasicNetwork(NetworkAPIDemo.java:111)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.<init>(NetworkAPIDemo.java:79)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.main(NetworkAPIDemo.java:245)
Exception in thread "main" java.lang.NullPointerException
        at org.numenta.nupic.network.sensor.BatchedCsvStream.<init>(BatchedCsvStream.java:355)
        at org.numenta.nupic.network.sensor.BatchedCsvStream.batch(BatchedCsvStream.java:601)
        at org.numenta.nupic.network.sensor.FileSensor.<init>(FileSensor.java:79)
        at org.numenta.nupic.network.sensor.FileSensor.create(FileSensor.java:110)
        at org.numenta.nupic.network.sensor.Sensor.create(Sensor.java:75)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.createBasicNetwork(NetworkAPIDemo.java:111)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.<init>(NetworkAPIDemo.java:79)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.main(NetworkAPIDemo.java:245)

```

---

<div class="post-metadata">

**Author:** ![cogmission](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/cogmission/32/11_2.png) [@cogmission](https://discourse.numenta.org/u/cogmission)\
**Post date:** [May 21, 2016, 2:34am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/4 "2016-05-21T02:34:01Z")

</div>

This is not a good medium to help you debug this…

Can you join me in the Gitter chat room? [https://gitter.im/numenta/htm.java](https://gitter.im/numenta/htm.java)

If not now then let me know when?

---

<div class="post-metadata">

**Author:** ![cogmission](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/cogmission/32/11_2.png) [@cogmission](https://discourse.numenta.org/u/cogmission)\
**Post date:** [May 21, 2016, 2:41am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/5 "2016-05-21T02:41:51Z")

</div>

Did you go to the directory where the jar file is after downloading, and type:

`java -jar NAPI-Hotgym-Demo-v0.6.8-alpha.jar`

??

That works fine for me? Do you have Java 8 installed?

Also… the “%” signs in the reported path error lets me know there is _maybe_ something going on with the way you’re running it?

---

<div class="post-metadata">

**Author:** ![cogmission](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/cogmission/32/11_2.png) [@cogmission](https://discourse.numenta.org/u/cogmission)\
**Post date:** [May 21, 2016, 10:48am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/6 "2016-05-21T10:48:20Z")

</div>

@Addonis

C:\Users\Ayumi\Desktop\Nupic,%20mysql,%20etc\htm.java-examples-master\src\main\java\org\numenta\nupic\examples\napi\hotgym\NAPI-Hotgym-Demo-v0.6.8-alpha.jar

Are you still there? This is not a valid path in any operating system? How do you expect the file to be located when the path has commas and percent signs in it? 🙂

I just downloaded this on a “blank” account and it runs perfectly. Please try and run it with the proper command using Java 8?

`java -jar NAPI-Hotgym-Demo-v0.6.8-alpha.jar`

---

<div class="post-metadata">

**Author:** ![Addonis](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/addonis/32/342_2.png) [@Addonis](https://discourse.numenta.org/u/Addonis)\
**Post date:** [May 21, 2016, 12:21pm UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/7 "2016-05-21T12:21:16Z")

</div>

Sorry, I didn’t even notice that Matt forked the thread. I don’t really need to use the Java version if I can get the Python version to work since I think I understand Python code a little better.

Anyway, the percent signs are not in the actual name of the directory, they only show up on a web page when you copy and paste the actual directory name, commas are fine to put into a directory name though. Besides, I actually switched to the directory of the file instead of running it from another directory, so the names of the directories didn’t really matter…

I also tried running that Java code on a Ubuntu machine, and my friend also ran it on his computer. It’s basically the same exact error each time.

The error is not that it can’t find the actual jar file or anything. It knows where it is, but when it actually tries to run the jar file, it fails somewhere. So maybe the problem is with my dependencies or missing file in the .jar

Regarding the version: I just installed the latest JDK from Oracle’s website on my Windows machine. And on Linux I am using Openjdkd version “1.8.0\_91”, Runtime Environment build 1.8.0.91-8u91-b14-0ubuntu~15.10.1-b14.

---

<div class="post-metadata">

**Author:** ![cogmission](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/cogmission/32/11_2.png) [@cogmission](https://discourse.numenta.org/u/cogmission)\
**Post date:** [May 22, 2016, 10:35am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/8 "2016-05-22T10:35:27Z")

</div>

@Addonis I believe something changed in terms of programmatic file access of files within the Jar that you’re running a program from. The HotGym csv file has to be loaded, and I had a similar problem when I rewrote the code for the other demos (i.e. BreakingNews & FoxEats).

I can’t reproduce this one though! It works fine for me - can you try running the other demos (you’ll need to get a Free [Cortical.io](http://Cortical.io) key before you do)? I will work on getting a dev environment up on my Windows partition - maybe I can reproduce it there?

Can anyone else reproduce this?

---

<div class="post-metadata">

**Author:** ![Addonis](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/addonis/32/342_2.png) [@Addonis](https://discourse.numenta.org/u/Addonis)\
**Post date:** [May 22, 2016, 3:05pm UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/9 "2016-05-22T15:05:49Z")

</div>

> [@cogmission](#):
>
> Can anyone else reproduce this?

My friend ran it on his computer. He also does Java programming so he has all the Java stuff installed but it didn’t work for him either.

* * *

> [@cogmission](#):
>
> can you try running the other demos

getting another error about missing class now, I’ll try to fix it later

---

<div class="post-metadata">

**Author:** ![cogmission](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/cogmission/32/11_2.png) [@cogmission](https://discourse.numenta.org/u/cogmission)\
**Post date:** [May 22, 2016, 3:35pm UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/10 "2016-05-22T15:35:23Z")

</div>

I run all of these just fine… There has to be something going on with your setup…?

@rhyolight can you try running these?

`java -jar NAPI-Hotgym-Demo-v0.6.8-alpha.jar`  
`java -jar breaking-news-demo-v0.6.8-alpha.jar -K<your api key>`  
`java -jar fox-eats-demo-v0.6.8-alpha.jar -K<your api key>`

---

<div class="post-metadata">

**Author:** ![Addonis](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/addonis/32/342_2.png) [@Addonis](https://discourse.numenta.org/u/Addonis)\
**Post date:** [May 23, 2016, 1:10am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/11 "2016-05-23T01:10:49Z")

</div>

Running on Windows 10 because they don’t work on my Ubuntu machine (tells me a class is missing).:

> [@cogmission](#):
>
> java -jar NAPI-Hotgym-Demo-v0.6.8-alpha.jar

```auto
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at org.numenta.nupic.network.sensor.FileSensor.getJarEntryStream(FileSensor.java:148)
        at org.numenta.nupic.network.sensor.FileSensor.<init>(FileSensor.java:78)
        at org.numenta.nupic.network.sensor.FileSensor.create(FileSensor.java:110)
        at org.numenta.nupic.network.sensor.Sensor.create(Sensor.java:75)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.createBasicNetwork(NetworkAPIDemo.java:111)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.<init>(NetworkAPIDemo.java:79)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.main(NetworkAPIDemo.java:245)
Exception in thread "main" java.lang.NullPointerException
        at org.numenta.nupic.network.sensor.BatchedCsvStream.<init>(BatchedCsvStream.java:355)
        at org.numenta.nupic.network.sensor.BatchedCsvStream.batch(BatchedCsvStream.java:601)
        at org.numenta.nupic.network.sensor.FileSensor.<init>(FileSensor.java:79)
        at org.numenta.nupic.network.sensor.FileSensor.create(FileSensor.java:110)
        at org.numenta.nupic.network.sensor.Sensor.create(Sensor.java:75)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.createBasicNetwork(NetworkAPIDemo.java:111)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.<init>(NetworkAPIDemo.java:79)
        at org.numenta.nupic.examples.napi.hotgym.NetworkAPIDemo.main(NetworkAPIDemo.java:245)

```

Maybe I have to set some environment variables for Java and/or Nupic?

* * *

> [@cogmission](#):
>
> java -jar breaking-news-demo-v0.6.8-alpha.jar -K\<your api key\>

Breaking News demo works on Windows 10.

Although I don’t know if it’s doing anything, because it keeps saying “failed json” and failed “tweet” in my console. And the anomaly graph is always flat.

```auto
failed json: {'text': "RT @BBCBreaking: Scotland's economy grew 0.6% in third quarter of 2012, taking it out of recession - Scottish government", 'created_at': 'Fri Feb 01 12:04:03 2013'}
failed tweet: BBCBreaking There s No Hope For This World With People Like That u00a31000 For An Innocent Life The Contractor Should Be Held Accountable Too
failed json: {'text': "@BBCBreaking There's No Hope For This World With People Like That. \\u00a31000 For An Innocent Life, The Contractor Should Be Held Accountable Too", 'created_at': 'Fri Feb 01 12:37:24 2013'}
failed tweet: BBCBreaking Russian rocket carrying US communications satellite plunges into Pacific Ocean shortly after launch via BBCDanielS
failed json: {'text': 'RT @BBCBreaking: Russian rocket - carrying US communications satellite - plunges into Pacific Ocean shortly after launch - via @BBCDanielS', 'created_at': 'Fri Feb 01 12:52:15 2013'}
failed tweet: BBCBreaking One dead after apparent suicide bombing outside US embassy in Turkey s capital Ankara state media t co XUKRGVx1
failed json: {'text': "RT @BBCBreaking: One dead after apparent suicide bombing outside US embassy in #Turkey's capital #Ankara - state media http:\\/\\/t.co\\/XUKRGVx1", 'created_at': 'Fri Feb 01 13:03:17 2013'}

```

* * *

> [@cogmission](#):
>
> java -jar fox-eats-demo-v0.6.8-alpha.jar -K\<your api key\>

The [cortical.io](http://cortical.io) thing opens but when I press start it does nothing, and in my console I get some error messages:

```auto
>java -jar fox-eats-demo-v0.6.8-alpha.jar -K25216680-202q-11e6-a057-97f4c970893chj
f **** problem: file:/C:/Users/Ayumi/Desktop/Nupic,%20mysql,%20etc/htm.java-examples-master/src/main/java/org/numenta/nupic/examples/cortical_io/foxeats/fox-eats-demo-v0.6.8-alpha.jar!/org/numenta/nupic/datagen/foxeat.csv
adjust: file:/C:/Users/Ayumi/Desktop/Nupic,%20mysql,%20etc/htm.java-examples-master/src/main/java/org/numenta/nupic/examples/cortical_io/foxeats/fox-eats-demo-v0.6.8-alpha.jar!org/numenta/nupic/datagen/foxeat.csv
adjust url: file:/C:/Users/Ayumi/Desktop/Nupic,%20mysql,%20etc/htm.java-examples-master/src/main/java/org/numenta/nupic/examples/cortical_io/foxeats/fox-eats-demo-v0.6.8-alpha.jar!org/numenta/nupic/datagen/foxeat.csv
adjust retVal: C:\Users\Ayumi\Desktop\Nupic,%20mysql,%20etc\htm.java-examples-master\src\main\java\org\numenta\nupic\examples\cortical_io\foxeats\fox-eats-demo-v0.6.8-alpha.jar!org\numenta\nupic\datagen\foxeat.csv
java.io.FileNotFoundException: C:\Users\Ayumi\Desktop\Nupic,%20mysql,%20etc\htm.java-examples-master\src\main\java\org\numenta\nupic\examples\cortical_io\foxeats\fox-eats-demo-v0.6.8-alpha.jar (The system cannot find the path specified)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)
        at org.numenta.nupic.network.sensor.FileSensor.getJarEntryStream(FileSensor.java:155)
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemo.getInputDataStream(FoxEatsDemo.java:541)
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemo.readInputData(FoxEatsDemo.java:510)
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemoView.startNetwork(FoxEatsDemoView.java:158)
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemoView.lambda$9(FoxEatsDemoView.java:147)
        at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
        at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemo.readInputData(FoxEatsDemo.java:515)
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemoView.startNetwork(FoxEatsDemoView.java:158)
        at org.numenta.nupic.examples.cortical_io.foxeats.FoxEatsDemoView.lambda$9(FoxEatsDemoView.java:147)
        at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
        at java.lang.Thread.run(Unknown Source)

```

* * *

EDIT: I just tried running hotgym demo again on my Ubuntu, and it worked!

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [May 23, 2016, 3:48am UTC](https://discourse.numenta.org/t/help-with-htm-java-examples/469/12 "2016-05-23T03:48:37Z")

</div>

> [@cogmission](#):
>
> @rhyolight can you try running these?
> 
> java -jar NAPI-Hotgym-Demo-v0.6.8-alpha.jar  
> java -jar breaking-news-demo-v0.6.8-alpha.jar -K\<your api key\>  
> java -jar fox-eats-demo-v0.6.8-alpha.jar -K\<your api key\>

They all work for me.
