# FX2D Fails in Windows 11

**URL:** <https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577>\
**Category:** py5\
**Created:** [June 19, 2025, 8:54pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577 "2025-06-19T20:54:38Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 19, 2025, 8:54pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/1 "2025-06-19T20:54:38Z")

</div>

I am using the latest version of py5 (0.10.6). Its associated py5\_tools was used to install JavaFX on my Windows 11 operating system. The following code run in the Thonny editor fails on Windows 11; a window is created but there is no title and there is an accompanying error message. I am unable to add any controls to it. The same code runs without error on MacOS. I am unable to find where PSurfaceFX$ResizableCanvas is cast to a java.awt.Canvas which is apparently the source of the error. PSurfaceFX.java is located here:[_https://github.com/processing/processing4-javafx_](https://github.com/processing/processing4-javafx) and ResizableCanvas is one of its classes. I will be unable to add any controls to this window until the error is fixed. I can’t figure out why there is a cast of a javafx canvas to one of the old awt canvases; as far as I am aware it inherits nothing from it. Furthermore, why won’t it run on Windows 11 when it works ok on Mac.

**Code:**

```python
# Uses Imported mode for py5

import javafx

def setup():
  size(400,250,FX2D);
  window_title("FX2D Window")

```

**Error message:**

_java.lang.ClassCastException: class processing.javafx.PSurfaceFX$ResizableCanvas cannot be cast to class java.awt.Canvas (processing.javafx.PSurfaceFX$ResizableCanvas is in unnamed module of loader ‘app’; java.awt.Canvas is in module java.desktop of loader ‘bootstrap’)_

```auto
java.lang.ClassCastException: class processing.javafx.PSurfaceFX$ResizableCanvas cannot be cast to class java.awt.Canvas (processing.javafx.PSurfaceFX$ResizableCanvas is in unnamed module of loader 'app'; java.awt.Canvas is in module java.desktop of loader 'bootstrap')
	at py5.core.Sketch.setup(Sketch.java:195)
	at processing.core.PApplet.handleDraw(PApplet.java:2051)
	at processing.javafx.PSurfaceFX$1.handle(Unknown Source)
	at processing.javafx.PSurfaceFX$1.handle(Unknown Source)
	at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:239)
	at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:197)
	at javafx.graphics/javafx.animation.Timeline.doPlayTo(Timeline.java:172)
	at javafx.graphics/javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
	at javafx.graphics/com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:104)
	at javafx.graphics/javafx.animation.Animation.doTimePulse(Animation.java:1189)
	at javafx.graphics/javafx.animation.Animation$1.lambda$timePulse$0(Animation.java:207)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at javafx.graphics/javafx.animation.Animation$1.timePulse(Animation.java:206)
	at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer.timePulseImpl(AbstractPrimaryTimer.java:343)
	at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer$MainLoop.run(AbstractPrimaryTimer.java:266)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:571)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:353)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
	at java.base/java.lang.Thread.run(Thread.java:840)

```

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 19, 2025, 9:22pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/2 "2025-06-19T21:22:09Z")

</div>

May have found the problem; it’s in py5.core.Sketch.setup I think:

```auto
  public void setup() {
    if (success) {
      PSurface surface = getSurface();

      // request focus for Java2D and FX2D renderers on Windows and MacOS
      if (platform == WINDOWS && (sketchRenderer().equals(JAVA2D) || sketchRenderer().equals(FX2D))) {
        Canvas canvas = (Canvas) surface.getNative();
        canvas.setFocusable(true);
        canvas.requestFocus();
      } else if (platform == MACOS && (sketchRenderer().equals(JAVA2D) || sketchRenderer().equals(FX2D) || g.isGL())) {
        ThinkDifferent.activateSketchWindow();
      }

```

At the top is  
`import java.awt.Canvas;`

Maybe this should be _import javafx.scene.canvas.Canvas_?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 19, 2025, 9:56pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/3 "2025-06-19T21:56:55Z")

</div>

Hello @svan,

I can’t get anything FX2D to work.

Running this:

```auto
# Uses Imported mode for py5

import javafx

def setup():
  size(400,250,FX2D);
  window_title("FX2D Window")

```

I get these errors:

> **Errors \< Click to expand!**
>
> > Graphics Device initialization failed for : d3d, sw  
> > Error initializing QuantumRenderer: no suitable pipeline found  
> > java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found  
> > at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)  
> > at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:254)  
> > at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:264)  
> > at com.sun.javafx.perf.PerformanceTracker.logEvent(PerformanceTracker.java:100)  
> > at javafx.scene.Node.(Node.java:417)  
> > at processing.javafx.PGraphicsFX2D$FontCache.(Unknown Source)  
> > at processing.javafx.PGraphicsFX2D.(Unknown Source)  
> > at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
> > at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)  
> > at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
> > at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)  
> > at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)  
> > at processing.core.PApplet.makeGraphics(PApplet.java:1896)  
> > at processing.core.PApplet.createPrimaryGraphics(PApplet.java:1975)  
> > at processing.core.PApplet.initSurface(PApplet.java:10170)  
> > at processing.core.PApplet.runSketch(PApplet.java:10131)  
> > Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found  
> > at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)  
> > at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)  
> > at java.base/java.lang.Thread.run(Thread.java:840)  
> > java.lang.ExceptionInInitializerError  
> > at processing.javafx.PGraphicsFX2D$FontCache.(Unknown Source)  
> > at processing.javafx.PGraphicsFX2D.(Unknown Source)  
> > at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
> > at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)  
> > at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
> > at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)  
> > at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)  
> > at processing.core.PApplet.makeGraphics(PApplet.java:1896)  
> > at processing.core.PApplet.createPrimaryGraphics(PApplet.java:1975)  
> > at processing.core.PApplet.initSurface(PApplet.java:10170)  
> > at processing.core.PApplet.runSketch(PApplet.java:10131)  
> > Caused by: java.lang.RuntimeException: No toolkit found  
> > at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:276)  
> > at com.sun.javafx.perf.PerformanceTracker.logEvent(PerformanceTracker.java:100)  
> > at javafx.scene.Node.(Node.java:417)  
> > … 11 more  
> > Java exception thrown by Sketch.runSketch:  
> > java.lang.RuntimeException

Configuration:

- W10
- Thonny 4.1.7
- Thonny -py5Mode 0.4.7.a0
- Python 3.13.2
- py5 0.10.6.a0

Other code works.  
I tried this from example code (with modifications required):

> **MandelBrot Code Python \< Click to expand!**
>
> ```auto
> # Uses Imported mode for py5
> 
> """
> The Mandelbrot
> 
> Set
> by Daniel Shiffman.    
> 
> Simple rendering of the Mandelbrot set.
> """
> size(640, 360)
> 
> # Establish a range of values on the complex plane
> # A different range will allow us to "zoom" in or out on the fractal
> xmin = -3
> ymin = -1.25
> w = 5
> h = 2.5
> 
> background(255)
> # Make sure we can write to the pixels[] array.
> # Only need to do this once since we don't do any other drawing.
> load_pixels()
> # Maximum number of iterations for each point on the complex plane
> maxiterations = 100
> # x goes from xmin to xmax
> xmax = xmin + w
> # y goes from ymin to ymax
> ymax = ymin + h
> # Calculate amount we increment x,y for each pixel
> dx = float(xmax - xmin) / (width)
> dy = float(ymax - ymin) / (height)
> # Start y
> y = ymin
> for j in range(height):
> # Start x
> x = xmin
> for i in range(width):
> # Now we test, as we iterate z = z^2 + cm does z tend towards infinity?
> a = x
> b = y
> n = 0
> while n < maxiterations:
> aa = a * a
> bb = b * b
> twoab = 2.0 * a * b
> a = aa - bb + x
> b = twoab + y
> # Infinty in our finite world is simple, let's just consider it 16
> if aa + bb > 16.0:
> break # Bail
> n += 1
> # We color each pixel based on how long it takes to get to infinity
> # If we never got there, let's pick the color black
> if n == maxiterations:
> pixels[i + j * width] = color(0)
> else:
> # Gosh, we could make fancy colors here if we wanted
> pixels[i + j * width] = color(n * 16 % 255)
> x += dx
> y += dy
> update_pixels()
> 
> ```

Setting all this up was a challenge!  
Too many leftovers (old code, paths, environment variables, etc.) and I had to clean house first.

I started here:

> **[Welcome to py5! — py5 documentation](https://py5coding.org/)**

Is there a simpler way?

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 19, 2025, 10:04pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/4 "2025-06-19T22:04:49Z")

</div>

`I can’t get anything FX2D to work.`

Make sure that you have JavaFX installed. There are instructions in the reference below. You can then check your libraries to confirm that it was really done.

> **[How to Use Processing Libraries — py5 documentation](https://py5coding.org/how_tos/use_processing_libraries.html)**

If you still have trouble I can try and retrace what I had to do to get it to work. The Thonny package manager let me down; says it updated py5 when it didn’t really. Latest py5 version is here if you don’t already know: [Release Important Bug Fix · py5coding/py5generator · GitHub](https://github.com/py5coding/py5generator/releases/tag/py5-1304-0027-0.10.6a0)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 19, 2025, 10:14pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/5 "2025-06-19T22:14:38Z")

</div>

Thanks for offer to assist.

All sorted! Needed to add libraries… and it took a while to download!

_I get the same error as you now._ Do you have a fix for this?

I seem to have the latest of everything.

I will scrutinize things on my end later.

`:)`

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 20, 2025, 12:55am UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/6 "2025-06-20T00:55:23Z")

</div>

> [@glv](#):
>
> Do you have a fix for this?

See my second post for what I think is a solid theory. I can easily edit the py5.core.Sketch.setup file but am hung up on how to recompile it so I can test it.

Here’s some pretty good evidence that my theory is correct. Try swapping the last two import calls and see the difference. On MacOS the following code generates the same error message that was observed on Windows 11. The title isn’t set and draw() becomes non-functional.

```processing
import processing.javafx.*;
import java.awt.Canvas;
//import javafx.scene.canvas.Canvas;

void setup(){
  size(350,200,FX2D);
  surface.setTitle("JavaFX Default Canvas");
  Canvas canvas = (Canvas)surface.getNative();
  println("canvas =",canvas);
}

void draw(){
  fill(0,255,0);
  circle(100,100,100);
}

```

Error:  
`ClassCastException: class processing.javafx.PSurfaceFX$ResizableCanvas cannot be cast to class java.awt.Canvas (processing.javafx.PSurfaceFX$ResizableCanvas is in unnamed module of loader 'app'; java.awt.Canvas is in module java.desktop of loader 'bootstrap')`

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 20, 2025, 2:11pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/7 "2025-06-20T14:11:51Z")

</div>

> [@svan](#):
>
> I can easily edit the py5.core.Sketch.setup file but am hung up on how to recompile it so I can test it.

I got as far as this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/3/73bbbabd336ecb95b84811ce0b7eefd13e920181.png)

@hx2A Can you provide some insight into building this?

I see work is being done on this:

> <https://github.com/py5coding/py5generator/issues/666>
>
> The following demo fails in Windows 11 after installing JavaFX with py5\_tools us…ing version 0.10.6 py5. A window is created but the title is not added and the window will not accept JavaFX controls. There is also an error message shown below.
> \`\`\`python
> \# Uses Imported mode for py5
> 
> import javafx
> 
> def setup():
> size(600,600,FX2D)
> window\_title("JavaFX Default Wnd")
> \`\`\`
> \*\*Error message:\*\*
> 
> \`\`\`
> java.lang.ClassCastException: class processing.javafx.PSurfaceFX$ResizableCanvas cannot be cast to class java.awt.Canvas (processing.javafx.PSurfaceFX$ResizableCanvas is in unnamed module of loader 'app'; java.awt.Canvas is in module java.desktop of loader 'bootstrap')
> at py5.core.Sketch.setup(Sketch.java:195)
> at processing.core.PApplet.handleDraw(PApplet.java:2051)
> at processing.javafx.PSurfaceFX$1.handle(Unknown Source)
> at processing.javafx.PSurfaceFX$1.handle(Unknown Source)
> at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:239)
> at javafx.graphics/com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:197)
> at javafx.graphics/javafx.animation.Timeline.doPlayTo(Timeline.java:172)
> at javafx.graphics/javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
> at javafx.graphics/com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:104)
> at javafx.graphics/javafx.animation.Animation.doTimePulse(Animation.java:1189)
> at javafx.graphics/javafx.animation.Animation$1.lambda$timePulse$0(Animation.java:207)
> at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
> at javafx.graphics/javafx.animation.Animation$1.timePulse(Animation.java:206)
> at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer.timePulseImpl(AbstractPrimaryTimer.java:343)
> at javafx.graphics/com.sun.scenario.animation.AbstractPrimaryTimer$MainLoop.run(AbstractPrimaryTimer.java:266)
> at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:571)
> at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555)
> at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548)
> at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:353)
> at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
> at javafx.graphics/com.sun.glass.ui.win.WinApplication.\_runLoop(Native Method)
> at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
> at java.base/java.lang.Thread.run(Thread.java:840)
> 
> \`\`\`
> \*\*Possible Fix:\*\*
> The error appears to be in \_py5.core.Sketch.setup\_.
> \_import java.awt.Canvas\_ should be changed to \*\*import javafx.scene.canvas.Canvas\*\* in my opinion.

`:)`

---

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [June 20, 2025, 2:26pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/8 "2025-06-20T14:26:34Z")

</div>

The build process is documented here:

> **[Build Process — py5 documentation](https://py5coding.org/developer/build_process.html)**

However - note that I’ve never actually run the build on Windows, so there might be platform specific problems in the build process. I do all development on Linux and MacOS. I will test on all platforms but writing code on Windows is not for me.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 20, 2025, 4:57pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/9 "2025-06-20T16:57:00Z")

</div>

> [@hx2A](#):
>
> I do all development on Linux and MacOS. I will test on all platforms but writing code on Windows is not for me.

I do not have a Linux box but will consider setting up a VM with [Oracle VirtualBox](https://www.virtualbox.org/) for these tasks.

It has been a while and I am sure a lot has changed since I last used it.

Can you recommended or point me in the right direction to a version of Linux?  
Feedback from other users welcome.

I will mostly use for things like programming.

`:)`

---

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [June 20, 2025, 5:40pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/10 "2025-06-20T17:40:23Z")

</div>

> [@glv](#):
>
> I do not have a Linux box but will consider setting up a VM with [Oracle VirtualBox](https://www.virtualbox.org/) for these tasks.

If you have Windows and would like to try Linux, I would recommend giving the Windows Subsystem a try. You can have Linux run alongside Windows and work in a terminal.

> **[Install WSL](https://learn.microsoft.com/en-us/windows/wsl/install)**
>
> Install Windows Subsystem for Linux with the command, wsl --install. Use a Bash terminal on your Windows machine run by your preferred Linux distribution - Ubuntu, Debian, SUSE, Kali, Fedora, Pengwin, Alpine, and more are available.

---

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [June 20, 2025, 5:42pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/11 "2025-06-20T17:42:53Z")

</div>

But for programming, you should use whatever works best for you! I use Linux and MacOS because that is what works best for me. I don’t want to imply there is some kind of objective reality where Linux is better than other options or that Linux is the best choice for everyone. Find where you are comfortable programming and use that.

---

<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:** [June 20, 2025, 6:37pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/12 "2025-06-20T18:37:01Z")

</div>

> [@glv](#):
>
> I do not have a Linux box but will consider setting up a VM with [Oracle VirtualBox](https://www.virtualbox.org/) for these tasks.

You should consider a distro which is lightweight (like the XFCE desktop environment), never needs to be upgraded (rolling-release model) and has everything setup & ready to use.

For all of those criteria, I know these 2 Linux distros:

1. Garuda Linux XFCE:

> **[Garuda Linux - your opinionated Linux distro](https://garudalinux.org/editions)**

1. Manjaro XFCE:

> **[Manjaro Image Downloads](https://manjaro.org/products/download/x86/)**
>
> Choose from major Linux Desktop environments to run Manjaro on your computer.

You should be able to virtualize any of those distros w/ good performance.

---

<div class="post-metadata">

**Author:** ![hx2A](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hx2a/32/14322_2.png) [@hx2A](https://discourse.processing.org/u/hx2A)\
**Post date:** [June 20, 2025, 6:41pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/13 "2025-06-20T18:41:37Z")

</div>

XFCE is a nice, lightweight, and accessible desktop environment. It’s a good choice.

I have done some investigation of this problem and I see that although the code change is simple, getting it to compile will require some upgrades/improvements to the build process that I was going to do eventually anyway. Give me some time to work on this first.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 20, 2025, 7:35pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/14 "2025-06-20T19:35:48Z")

</div>

Finally got javafx in py5 to run in Windows 11. It turned out to be difficult to get p5 to recognize javafx when editing the Sketch file. However, the block of code that was causing the error just setFocus which is not really necessary anyway, so I REMmed out all of this code and recompiled the py5.jar and it worked. No more error, the output is good and so far see no ill-effects from deleting that code block.  
**Output:**

 ![w11](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/5/b596666134303e1a31ca10eb226d8741a8c1da6f.png)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 20, 2025, 7:40pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/15 "2025-06-20T19:40:41Z")

</div>

> [@svan](#):
>
> Finally got javafx in py5 to run in Windows 11

Please provide enough details that anyone (with some comfort level and experience) can reproduce.

In steps please.

Thanks!

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 20, 2025, 8:11pm UTC](https://discourse.processing.org/t/fx2d-fails-in-windows-11/46577/16 "2025-06-20T20:11:40Z")

</div>

1. Here’s what I did to py5.core.Sketch.setup:

```processing
// import java.awt.Canvas;

... 

  public void setup() {
    if (success) {
      PSurface surface = getSurface();

      // request focus for Java2D and FX2D renderers on Windows and MacOS
      if (platform == WINDOWS && (sketchRenderer().equals(JAVA2D) || sketchRenderer().equals(FX2D))) {
       // Canvas canvas = (Canvas) surface.getNative();
      // canvas.setFocusable(true);
      // canvas.requestFocus();

      } else if (platform == MACOS && (sketchRenderer().equals(JAVA2D) || sketchRenderer().equals(FX2D) || g.isGL())) {
        ThinkDifferent.activateSketchWindow();
      }

      if (py5IconPath != null && !(g instanceof PGraphicsOpenGL)) {
        try {
          surface.setIcon(loadImage(py5IconPath));
        } catch (Exception e) {
        }
      }

```

1. I followed the build instructions for py5 at the url given above (had to make some modifications to the code to accommodate my system)

2. I recompiled everything on MacOS and put a .zip file of _py5.jar_ on DropBox so I could get it on my Windows 11 system: _[https://www.dropbox.com/scl/fi/1eupsrgqpe2pwr7bidzgk/py5.jar.zip?rlkey=jalvfxwgq522e7g53vs6wk811&st=tzy7534i&dl=0](https://www.dropbox.com/scl/fi/1eupsrgqpe2pwr7bidzgk/py5.jar.zip?rlkey=jalvfxwgq522e7g53vs6wk811&st=tzy7534i&dl=0)_

You’re welcome to try it also.
