# Using FastNoise

**URL:** https://discourse.processing.org/t/using-fastnoise/5587
**Category:** Libraries
**Created:** [November 16, 2018, 9:08am UTC](https://discourse.processing.org/t/using-fastnoise/5587 "2018-11-16T09:08:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![drc](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@drc](https://discourse.processing.org/u/drc)
#### Post date: [November 16, 2018, 9:08am UTC](https://discourse.processing.org/t/using-fastnoise/5587/1 "2018-11-16T09:08:39Z")

</div>

Hi,

I’d like to use the FastNoise library. I drag&dropped the FastNoise.java to a new sketch, and with the following code:

```auto
FastNoise myNoise;

void setup() {
  myNoise.SetNoiseType(FastNoise.NoiseType.SimplexFractal);
}

```

I get the NullPointerException error, highlighting the only line in setup.

Could you please help me here? How should I use this library?

thanks!

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [November 16, 2018, 9:54am UTC](https://discourse.processing.org/t/using-fastnoise/5587/2 "2018-11-16T09:54:14Z")

</div>

> [@drc](#):
>
> I get the NullPointerException error, highlighting the only line in **setup()**.

- You had merely declared field _myNoise_ w/o initializing it: `FastNoise myNoise;`
- A reference field always defaults to `null` under Java.
- We can’t do anything to a `null` value but checking out whether a variable has it stored.

> [@drc](#):
>
> `myNoise.SetNoiseType(FastNoise.NoiseType.SimplexFractal);`

Ru sure it’s **SetNoiseType()**? Under Java’s naming conventions that should be named: **setNoiseType()**. ☕

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 16, 2018, 10:37am UTC](https://discourse.processing.org/t/using-fastnoise/5587/3 "2018-11-16T10:37:44Z")

</div>

Here’s the link to the library:

> **[Auburns/FastNoise\_Java](https://github.com/Auburns/FastNoise_Java)**
>
> FastNoise Java Version. Contribute to Auburns/FastNoise\_Java development by creating an account on GitHub.

Apparently it is `SetNoiseType` and not `setNoiseType`. For some reason all the methods are upper case.

In Ubuntu I had to download one dependency to make it work:

```
$ sudo apt install libvecmath-java
$ dpkg -L libvecmath-java | grep jar$

/usr/share/java/vecmath-1.5.2.jar
/usr/share/java/vecmath.jar

$ cd into/my/sketch/folder
$ mkdir code
$ cp /usr/share/java/vecmath.jar code/

```

Then I could run

```auto
FastNoise myNoise;

void setup() {
  myNoise = new FastNoise();
  myNoise.SetNoiseType(FastNoise.NoiseType.SimplexFractal);
  println(myNoise.GetNoise(0.1, 0.2, 0.3));
}

```

The examples in GitHub look interesting. For example:

 ![](https://yyz2.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c8589c6e09b99e0ab4363956d66c87689a736fc4.png)

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 16, 2018, 10:41am UTC](https://discourse.processing.org/t/using-fastnoise/5587/4 "2018-11-16T10:41:12Z")

</div>

By the way, [this change](https://github.com/Auburns/FastNoise_Java/pull/1/files?utf8=%E2%9C%93&diff=unified&w=1) removes the dependency on javax.vecmath, making it self contained.

---

<div class="post-metadata">

### Author: ![drc](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@drc](https://discourse.processing.org/u/drc)
#### Post date: [November 17, 2018, 10:28am UTC](https://discourse.processing.org/t/using-fastnoise/5587/5 "2018-11-17T10:28:13Z")

</div>

Thank you both! Now it works fine (I’ve already downloaded the vecmath before).
