# I have a problem with coding Java

**URL:** https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968
**Category:** Electronics (Arduino, etc.)
**Created:** [June 29, 2021, 5:49pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968 "2021-06-29T17:49:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![christiank79](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/christiank79/32/11861_2.png) [@christiank79](https://discourse.processing.org/u/christiank79)
#### Post date: [June 29, 2021, 5:49pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968/1 "2021-06-29T17:49:39Z")

</div>

Hello,  
I have a problem with coding I want to save a picture with SVG.  
This is the code:

```auto
import processing.serial.*;
String serialPort = "COM4"; // the name of the USB port
int imageType = 1; // 0=svg, 1=png, 2=both
String filePath = "data/vale.svg"; // the SVG file path
String pngPath = "data/vale.png"; // png file path
double precision = 0.1; // precision for interpolating curves (smaller = finer)
float maxdim = 60; // maximum dimension in mm (either height or width)
boolean rotated = false; // true rotates 90 degrees: (maxy-y)->x, x->y
boolean sendIt = false; // true=sends the data, false=just draws to screen
boolean useHatches = true; // to generate hatches for filling
int hatchLevels = 4; // the number of hatch levels for grayscale
float hatchSlope = -1; // negative to slant up to the right
float hatchInterval = 0.02; // multiplied by maxdim to give interval in mm
int hatchThreshold = 127; // anything below this value will be hatched
int hatchThresholdMax = 200; // max of the range when using multiple hatches
float minHatchLength = 0.1; // don't draw too short hatches

ArrayList<Point> allpoints;
ArrayList<Integer> penMoves;
boolean penDown;
int vectorPointCount, vectorPenCount;

boolean workFinished, generatePoints;
PShape svgShape;
float maxx, maxy, minx, miny;
int pixWidth, pixHeight;
boolean hatchesReady;

Serial sPort; 

void setup() {
  size(400, 400);
  allpoints = new ArrayList<Point>();
  penMoves = new ArrayList<Integer>();
  penDown = false;
  workFinished = false;
  generatePoints = true;
  hatchesReady = false;
  vectorPointCount = 0;
  // In SVG mode, read the data file
  // This is only done once, so it is in setup()
  if(imageType == 0 || imageType == 2){
    readData(filePath);
    vectorPointCount = allpoints.size();
    vectorPenCount = penMoves.size();
    if (allpoints.size()==0) {
      println("There was an error in the data file");
      while(true);
    }
  }else{
    // other mode must use hatches
    useHatches = true;
    // and the size needs to be found
    minx = 0;
    miny = 0;
    PImage im = loadImage(pngPath);
    if(im.width > im.height){
      maxx = maxdim;
      maxy = (im.height*maxdim)/im.width;
    }else{
      maxy = maxdim;
      maxx = (im.width*maxdim)/im.height;
    }
  }

```

I want to post all coding,but my coding is very long about 44244 characters, body limited is 32000.  
Thank you

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [June 29, 2021, 8:03pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968/2 "2021-06-29T20:03:52Z")

</div>

[https://processing.org/reference/save\_.html](https://processing.org/reference/save_.html)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 29, 2021, 8:49pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968/3 "2021-06-29T20:49:52Z")

</div>

[https://processing.org/reference/libraries/svg/index.html](https://processing.org/reference/libraries/svg/index.html)

---

<div class="post-metadata">

### Author: ![christiank79](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/christiank79/32/11861_2.png) [@christiank79](https://discourse.processing.org/u/christiank79)
#### Post date: [June 30, 2021, 3:49pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968/4 "2021-06-30T15:49:36Z")

</div>

Hello,  
now I have a problem with this code, line number 149:  
 ![screenShot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d272511a75a8795b7e76751809137221912ff646.png)  
What can I do? Thank you.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 30, 2021, 4:15pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-coding-java/30968/5 "2021-06-30T16:15:30Z")

</div>

Looks like pngPath is wrong

Please check spelling, it’s case-sensitive

Having said that, it’s better to load in setup() and not later
