Importing Java libraries into embed Processing sketch online

Hello, I’m trying to embed a Processing sketch onto an HTML page, which uses Java libraries, I’ve been following this guide.
Processing on the web does not support imported libraries, which is probably why the program works perfectly on the IDE but not on my webpage. How do I manually add these libraries to my code? Can I just download them and put them in folders somehow?

This is the part of my code that needs to be replaced:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

Hi @zellwd,

You can’t do it that way on client-side js. The libraries are for java not for Javascript which processingJS is build for.
Further, ProcessingJS is outdated, therefore you should use p5js.
You should adapt the java code to Javascript code. Not all thing from java are possible in js but most.
If you provide the java code, resp. processing java sketch you want to convert to js, we could try to help you …

Cheers
— mnse

Hi @mnse and thank you for your answer.
So if I convert my Processing code to p5.js I would have to convert the java libraries I wanted to import too? Is there no way to import java libraries into a p5.js program?
Thank you

Do you really need a BufferedReader?

Isn’t loadStrings() & saveStrings() enough for your sketch?
https://GoToLoop.GitHub.io/processing-js.github.io/reference/loadStrings_/
https://GoToLoop.GitHub.io/processing-js.github.io/reference/saveStrings_/

B/c your Java Mode sketch would be able to run on the web if you stick w/ Processing’s API:
https://GoToLoop.GitHub.io/processing-js.github.io/reference/

Hi @zellwd,

All depends on your code…

P5js and processing java build up a similar framework ie. setup/draw.

Regarding the libraries. No! Java and Javascript are different things.

But if you want to implement backend logic with java you can use a server-site approach ie. RestAPI calls etc.
But that mean you need an appserver running ie. tomcat.

As said, all depends on your code and what it does … and if you could tell what libraries you want to use for what we can see if there are similar libraries for js…

Cheers
— mnse