Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Compiler doesn't recognise classpath jars #1

Closed
PranavPurwar opened this issue May 3, 2022 · 6 comments
Closed

Compiler doesn't recognise classpath jars #1

PranavPurwar opened this issue May 3, 2022 · 6 comments

Comments

@PranavPurwar
Copy link

PranavPurwar commented May 3, 2022

Upon running it on a test app, the nb-javac-android compiler complains of no classpath containing java.lang.* class files even tho it is present whereas nb-javac from CodeAssist (again with the same arguments) works fine. This seems like an issue with scanning jar files?

@itsaky
Copy link
Member

itsaky commented May 3, 2022

First of all, the version of nb-javac was built with AndroidIDE in mind. So it is different from the version that CodeAssist uses.

To get this javac working with your project, you have to generate a minimal JDK with only the classes from android.jar and then use it with this nb-javac-android. You can use androidide-jdk-transform to generate such JDK images.

Apart from this, this nb-javac has names of classes from AndroidIDE hardcoded in it. For example, it uses the Environment class to get the path to the transformed JDK image as seen here.

@itsaky itsaky changed the title bug: Compiler doesn't recognise classpath jars Compiler doesn't recognise classpath jars May 3, 2022
@itsaky
Copy link
Member

itsaky commented May 3, 2022

This is clearly not a bug. It is just how this nb-javac-android is designed.

@PranavPurwar
Copy link
Author

PranavPurwar commented May 3, 2022

No issues, i didn't knew that earlier as it was published on maven.

@itsaky itsaky closed this as completed May 3, 2022
@PranavPurwar
Copy link
Author

PranavPurwar commented Jun 23, 2022

Thanks! It's working now after creating the com.itsaky.androidide.utils.Environment file with a static field containing the system modules path. However, I think It'd be more convenient to set up if the class path is not hardcoded/is changeable

@itsaky
Copy link
Member

itsaky commented Jul 8, 2022

You can now configure nb-javac-android to use a custom JAVA_HOME without creating the Environment class. Simply set the androidide.java.home property with System.setProperty(String, String). Use the PROP_ANDROIDIDE_JAVA_HOME field in JavacConfigProvider

See JavacConfigProvider for more detail.

@itsaky
Copy link
Member

itsaky commented Jul 8, 2022

This will be available in release 17.0.0.2 which will take few minutes to get published.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants