Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassGraph thinks the application jars are JRE_LIB_OR_EXT_JARS #816

Open
emaayan opened this issue Dec 31, 2023 · 5 comments
Open

ClassGraph thinks the application jars are JRE_LIB_OR_EXT_JARS #816

emaayan opened this issue Dec 31, 2023 · 5 comments

Comments

@emaayan
Copy link

emaayan commented Dec 31, 2023

hi.. when working from the IDE classGraph works fine, how in runtime my applicaiton is order like so
. -> root folder
jre -> jre folder
lib -> folder for all my jars

scripts for runnig the app.

so when running the scripts the code in SystemJarFinder the code sees the folder jre and assume my root folder is the jdk,
even though it's not, so it takes all jars in lib folder as system jars ..

 if (javaHome != null && !javaHome.isEmpty()) {
            final File javaHomeFile = new File(javaHome);
            addJREPath(javaHomeFile);
            if (javaHomeFile.getName().equals("jre")) {
                // Try adding "{java.home}/.." as a JDK root when java.home is a JRE path
                final File jreParent = javaHomeFile.getParentFile();
                addJREPath(jreParent);
                **addJREPath(new File(jreParent, "lib"));**
                addJREPath(new File(jreParent, "lib/ext"));
         
        }

perhaps you could add a setting like don't assume jdk folder above jre

@lukehutch
Copy link
Member

Thanks for the report.

In every JDK release I have seen, the jre folder is within the JDK folder, if you have a JDK installed. I wonder how to do this in a more robust way...

What is your runtime environment?

@emaayan
Copy link
Author

emaayan commented Jan 9, 2024

you're assuming the existence if a jdk and not just a jre, what if for example you have just a custom built jre folder?

@lukehutch
Copy link
Member

Can you please suggest a robust way to detect the system lib and ext directories then?

@emaayan
Copy link
Author

emaayan commented Jan 9, 2024

just give the user an option to override the default behaviour, by supplying their own javahome
a lib folder for application jars can be a very common structure for most java apps.

@lukehutch
Copy link
Member

Is there likely to be some reliable way to tell between a JRE and a JDK?

I would want to check these variables across numerous releases, on all 3 major Java platforms, and for local install vs. system install:

https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html

If there's a way to reliably detect JRE (maybe the string "Runtime Environment" in one of the variables?), then I can avoid assuming JRE is always contained within a JDK dir.

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

No branches or pull requests

2 participants