jsweet icon indicating copy to clipboard operation
jsweet copied to clipboard

Getting the following ERROR Namespace 'java' has no exported member 'awt' -- But we are including AWT maven dependencies

Open xeccgtt opened this issue 4 years ago • 4 comments

We are getting the following error. We downloaded the j4ts-awt-swing maven dependencies, compiled them with jsweet.transpiler.version: 2.3.6-SNAPSHOT and jsweet.core.version: 6.0.3. We include this version in our local maven repo. We still got these errors.

We copied the j4ts-awt-swing files to a down loaded copy of j4ts. We did this to resolve to try to resolve dependencies between j4ts and j4ts-awt-swing. We are just using the as the only local maven dependency.

What does this error mean? How doe we remove the error. I am road blocked by this. I can not move forward with jsweet or backward. I simply do not have enough knowledge about this error. I am using your libraries there should be a basic level of guidance on how to use them.

2020-06-01 12:57:23.023 INFO TypeScript2JavaScriptWithTscTranspiler:90 - Arrow.ts(58,31): error TS2694: Namespace 'java' has no exported member 'awt'. 2020-06-01 12:57:23.023 ERROR output:55 - namespace 'java' has no exported member 'awt' at Arrow.java(86)

xeccgtt avatar Jun 01 '20 17:06 xeccgtt

Umm... Not sure with the info I have here, but something must be wrong with the j4ts-awt-swing dependency configuration since this TS compilation error simply means that package awt is not found. So at some point the j4ts-awt-swing TS definition file is not found (or wrongly generated).

2 pieces of advice:

  1. Make sure that you manage to transpile and run a basic swing/awt program, following for instance the example in https://github.com/cincheo/applet-migration-example
  2. j4ts-awt-swing is a prototype which is far from being complete. If you are using this, you have to be ready to 1/ improve the swing/awt support because your application will probably use unsupported elements 2/ refactor your swing application to separate the business logic from the view and simplify the UI

renaudpawlak avatar Jun 01 '20 19:06 renaudpawlak

What is the TS definition file?

Both the j4ts-awt-swing and j4ts-awt-file repo seem to have problems compiling with the newer transpiler. There POM has very old dependence that do not seem to be available any longer.

I will take a look at the repo you include. But I am not sure it will help.

xeccgtt avatar Jun 01 '20 19:06 xeccgtt

The TS (TypeScript) definition file is the API file generated by JSweet so that the TypeScript code will safely compile. The j4ts-awt-swing will have a generated TS def file that contains part of the supported awt/swing API made available to TypeScript/JavaScript.

Yes, these projects are outdated and have not been maintained for a while. At the time there were some experiments to show that it could work (and it works). However, I had too many other professional obligations to continue and maintain these experiments and people did not seem to believe it could actually work at the time. For some reasons, people seem to regain some interest in migrating Java to the Web and I think it could be nice to update these projects to the latest version of JSweet (since JSweet has evolved a lot since then as you mentioned).

It could be interesting to have a deeper discussion about your context and your expectations using JSweet.

renaudpawlak avatar Jun 01 '20 20:06 renaudpawlak

The motivation for using JSweet, j4ts, j4ts-file and jrts-awt-swing is to convert an Applet to html/java-script solution. Applets have been removed from Java 11 so we are looking for conversion tool.

What complicates matters is the Applet makes Socket calls to a Java application. For scaling purposes we were trying to push the processing the Applet does to browser.

xeccgtt avatar Jun 01 '20 20:06 xeccgtt