# Java Error: Could not initialize class sun.lwawt.macosx.LWCToolkit

**URL:** <https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961>\
**Category:** Bug Reports\
**Created:** [August 11, 2021, 1:34pm UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961 "2021-08-11T13:34:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 11, 2021, 1:34pm UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/1 "2021-08-11T13:34:52Z")

</div>

Hi,

So I’ve run into error that I’ve not encountered before when using VP and more specifically, using the plugin scripts mechanism.

To give some context, we use a Mac VM to execute scripts throughout the day. When I’m connected to the device using Screen Sharing, I am able to execute these commands from within the terminal no problem. eg; example of updating a VP project using the plugin script

`cd "/Applications/Visual Paradigm.app/Contents/Resources/app/scripts/" && sh UpdateTeamworkProject.sh -workspace "/Users/x/Library/Application Support/VisualParadigm/ws/" -project "/Users/x/Library/Application Support/VisualParadigm/ws/teamwork_client/projects/y/y.vpp"`

However when accessing the device using `ssh` and running the same script as above, I get the following error from java:

```auto
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.lwawt.macosx.LWCToolkit
	at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:47)
	at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:592)
	at java.desktop/sun.awt.CGraphicsEnvironment.<clinit>(CGraphicsEnvironment.java:73)
	at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:43)
	at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
	at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
	at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
	at v.aid.ad.a(:299)
	at v.aid.ad.g(:261)
	at v.avz.bm.a(:834)
	at v.avz.bm.a(:239)
	at v.avc.b.a(:83)
	at com.vp.cmd.UpdateTeamworkProject.a(:38)
	at com.vp.cmd.UpdateTeamworkProject.main(:23)

```

I am running the following version of VP: 16.1 and the current Java version is: 8 update 301.

Any help on this would be much appreciated.

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 12, 2021, 1:44am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/2 "2021-08-12T01:44:26Z")

</div>

Hi GregS,

Thank you for your post. Could you send me your log file for diagnosis? The article below shows you how to obtain the log:

> **[How to Obtain Log File from Visual Paradigm - Visual Paradigm Know-how](https://knowhow.visual-paradigm.com/technical-support/vp-log/)**
>
> Visual Paradigm keeps a textual record of actions that have occurred in a log file. It is usually about the activity and performance of the software as well as any problems that may occur. This page will demonstrate how to locate the log file in...

Then, please upload to:  
[https://files2.visual-paradigm.com/index.php/s/6avhY0Sq6NXlZwF](https://files2.visual-paradigm.com/index.php/s/6avhY0Sq6NXlZwF)

Password:  
jg67ogfe0ds65hvjdf

Note: Only Visual Paradigm staff can access the uploaded files.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 12, 2021, 7:47am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/3 "2021-08-12T07:47:19Z")

</div>

Thanks for responding @Jick . I’ve just uploaded the log file.

UPDATE:  
I’ve just done some further investigation. Within the Screen Sharing app, I opened up VP on the Mac VM; I also `ssh` onto the Mac VM and I executed the command shared in the original post. In doing so, it returns the following error:

```auto
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Workspace in use.

```

However, if I then create a new workspace, try to rerun the command using `ssh` in the terminal, I still get the same error as in the OP. It’s almost as though it can’t initialise the application or something when remotely connecting to that device.

I have tried doing the same approach as above but on an physical device (Mac Mini) as opposed to a VM and this doesn’t throw any problem. It updates a given project fine.

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 13, 2021, 12:58am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/4 "2021-08-13T00:58:15Z")

</div>

Hi GregS,

I have just downloaded your file and will forward it to our engineers to study. When there is any update, I will post it here.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 13, 2021, 5:18am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/5 "2021-08-13T05:18:25Z")

</div>

Hi GregS,

Could you try to set the environment variable HEADLESS=true before running the script?

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 13, 2021, 7:31am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/6 "2021-08-13T07:31:24Z")

</div>

Hi Jick,

Thanks for responding. I assume add that to the plugin.sh file? Currently its set to false.

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 16, 2021, 3:09am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/7 "2021-08-16T03:09:09Z")

</div>

Hi GregS,

I have forwarded your question to our engineers and will share the answer with you asap.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 16, 2021, 8:12am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/8 "2021-08-16T08:12:30Z")

</div>

Hi GregS,

Set the environment variable for a single session:  
export HEADLESS=true

or you can modify the plugin.sh file to change it permanently.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 16, 2021, 10:24am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/9 "2021-08-16T10:24:02Z")

</div>

Hi Jick,

I have updated the `plugin.sh` file with the change you mentioned however the `java.lang.NoClassDefFoundError` still persists when `ssh` onto the Mac VM.

`plugin.sh` file below:

```auto
#!/bin/sh
cd ../bin
if ["v$HEADLESS" = "v"]; then
    HEADLESS=true
fi

JAVA="../jre/bin/java"
if [! -f "$JAVA"]; then
    JAVA="../../jre/bin/java"
fi

if [! -f "$JAVA"]; then
    JAVA="../../jre.bundle/Contents/Home/jre/bin/java"
fi

if [! -f "$JAVA"]; then
    JAVA="../../.install4j/jre.bundle/Contents/Home/jre/bin/java"
fi

if [! -f "$JAVA"]; then
    JAVA="java"
fi

"$JAVA" -Xms4096m -Xmx8192m -XX:MaxPermSize=4096m -Djava.awt.headless=$HEADLESS -cp ...

```

You mentioned setting the environment variable for a single session, where in VP or what config file do I need to set this?

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 16, 2021, 11:44pm UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/10 "2021-08-16T23:44:04Z")

</div>

Hi GregS,

I will consult our engineers and get back to you as soon as I can.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 17, 2021, 2:45am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/11 "2021-08-17T02:45:25Z")

</div>

Hi GregS,

Is the trace the same? It could be the same error but with a different trace. If the trace is the same, then it is likely that the headless variable wasn’t applied correctly… If the trace is different, could you send me to have a look?

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 17, 2021, 7:48am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/12 "2021-08-17T07:48:22Z")

</div>

HI @Jick

Yes, the stack is the same error. Error shown below:

```auto
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.lwawt.macosx.LWCToolkit
	at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:47)
	at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:597)
	at java.desktop/sun.awt.CGraphicsEnvironment.<clinit>(CGraphicsEnvironment.java:72)
	at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:43)
	at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
	at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
	at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
	at v.aid.ad.a(:299)
	at v.aid.ad.g(:261)
	at v.avz.bm.a(:834)
	at v.avz.bm.a(:239)
	at v.avc.b.a(:83)
	at com.vp.cmd.UpdateTeamworkProject.a(:38)
	at com.vp.cmd.UpdateTeamworkProject.main(:23)

```

The log file contains the following:

```auto
[2021/08/17 08:45:28] [message] Aug 17, 2021 8:45:28 AM com.jidesoft.plaf.aqua.AquaPreferences loadGlobalPreferences

WARNING: AquaPreferences failed to load Mac OS X global system preferences - parseInt: unsupported byte count:16

[2021/08/17 08:45:28] [message] Connect to repository https://x.vpository.com [Success]

```

Just to add, I am running Big Sur on the Mac VM. The device in which it was working successfully on was using Catalina.

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 20, 2021, 6:55am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/13 "2021-08-20T06:55:33Z")

</div>

Hi GregS,

I’ve forwarded your reply to our engineers to study. When there is any news, I will let you know.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 20, 2021, 9:21am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/14 "2021-08-20T09:21:15Z")

</div>

Hi GregS,

First of all, please try to set in the environment variable, run:  
“HEADLESS=true ./plugin.sh”

We have developed a test program to help to diagnose the problem. Please down the zip here:

> **[ownCloud - A safe home for all your data](https://files2.visual-paradigm.com/index.php/s/pBUHWgNUxC8pHtV)**
>
> Test.zip is publicly shared

Then, unzip the downloaded file to obtain the Test.class file. Copy the Test.class file to the script folder. Then, change the last line of plugin.sh to:  
“$JAVA” -Xms4096m -Xmx8192m -XX:MaxPermSize=4096m -Djava.awt.headless=$HEADLESS -cp . Test

The output is expected to be:  
java.awt.headless: true  
GraphicsEnvironment.isHeadless(): true

Please try.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 23, 2021, 8:50am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/15 "2021-08-23T08:50:50Z")

</div>

Hi @Jick

As requested, I downloaded the file, unzipped and saved it within the scripts directory. I changed the `plugin.sh` as shown below:

```auto
#!/bin/sh
cd ../bin
if ["v$HEADLESS" = "v"]; then
    HEADLESS=true
fi

JAVA="../jre/bin/java"
if [! -f "$JAVA"]; then
    JAVA="../../jre/bin/java"
fi

if [! -f "$JAVA"]; then
    JAVA="../../jre.bundle/Contents/Home/jre/bin/java"
fi

if [! -f "$JAVA"]; then
    JAVA="../../.install4j/jre.bundle/Contents/Home/jre/bin/java"
fi

if [! -f "$JAVA"]; then
    JAVA="java"
fi

"$JAVA" -Xms4096m -Xmx8192m -XX:MaxPermSize=4096m -Djava.awt.headless=$HEADLESS -cp . Test

```

Then I run the following command within the terminal:

`sh Plugin.sh -project "/Users/admin/Library/Application Support/VisualParadigm/ws/teamwork_client/projects/X/X.vpp" `

However it returns the following:

```auto
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Error: Could not find or load main class Test
Caused by: java.lang.ClassNotFoundException: Test

```

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [August 30, 2021, 3:47am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/16 "2021-08-30T03:47:36Z")

</div>

Hi GregS,

Please try to remove “cd …/bin” for the test.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [August 31, 2021, 7:54am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/17 "2021-08-31T07:54:43Z")

</div>

Hi @Jick,

After removing the line you mentioned in the previous comment, I now get the following:

```auto
java.awt.headless: true
GraphicsEnvironment.isHeadless(): true

```

This gets returned when I am logged into the device directly and when ssh’ing onto the device too.

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [September 2, 2021, 4:03am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/18 "2021-09-02T04:03:58Z")

</div>

Hi GregS,

I’ve passed your reply to our engineering team. When there is a feedback I will let you know.

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![Jick](https://avatars.discourse-cdn.com/v2/letter/j/ea666f/32.png) [@Jick](https://forums.visual-paradigm.com/u/Jick)\
**Post date:** [September 2, 2021, 5:22am UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/19 "2021-09-02T05:22:23Z")

</div>

Hi GregS,

It seems that you are running UpdateTeamworkProject.sh but you set headless to plugin.sh

Best regards,  
Jick Yeung

---

<div class="post-metadata">

**Author:** ![GregS](https://avatars.discourse-cdn.com/v2/letter/g/bc79bd/32.png) [@GregS](https://forums.visual-paradigm.com/u/GregS)\
**Post date:** [September 2, 2021, 12:33pm UTC](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961/20 "2021-09-02T12:33:46Z")

</div>

Hi @Jick,

Thanks for pointing that out, that seemed to fix the issue! 🤦‍♂️

Out of curiosity on the physical device, we have set `HEADLESS=false` and yet we can still `SSH` onto the device and run VP without the UI. But on the Mac VM by setting it too true, it works.

[Next page](https://forums.visual-paradigm.com/t/java-error-could-not-initialize-class-sun-lwawt-macosx-lwctoolkit/16961.md?page=2)
