Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8013809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:44:06+00:00 2026-06-04T19:44:06+00:00

I wish to compile source without having the dependencies present on the machine. Example:

  • 0

I wish to compile source without having the dependencies present on the machine.
Example: File A.java:

import some.pkg.B; 
public class A extends B {...}

I don’t have B source present, I wish to hook either JavaFileManager or a custom ClassLoader in order to get the symbols in question (the package ‘some.package’ and class B) and then use a service I have that retrieves the source string.

The compiling code: (inputFiles has A.java)

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
CustomClassLoader classLoader = new CustomClassLoader();
StandardJavaFileManager standardfileManager = compiler.getStandardFileManager(this, null, null);
JavaFileManager fileManager = new CustomFileManager(standardfileManager, output, classLoader);
CompilationTask task = compiler.getTask(null, fileManager, this, null, null, inputFiles);
boolean result = task.call();

Hooks on JavaFileManager (getFileForInput..) and on my classloader (findClass, loadClass ..) didn’t triggered when compiling and I got error messages:

A.java:#: package some.pkg does not exist
A.java:#: cannot find symbol
symbol: class B

EDIT

After playing around with the API, going over JavaCompiler (older version) source and reading Compilation Overview I still can’t find an API hook I can use to provide me Symbols from the syntax trees. It seems that the API needs to get all resources based on package names as suggested by kschneid.
One workaround I thought about is running the JavaCompiler and analyze the error messages for missing symbols. That way I will know which symbols are needed, get them and recompile.
Any other workarounds / solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:44:08+00:00Added an answer on June 4, 2026 at 7:44 pm

    (I assume that you’re not really using a package name of “package” since that would just be illegal…)

    Your custom JavaFileManager should be getting its list method invoked. Hopefully this notation makes sense, but the combination of args to that method should look like this:

    [PLATFORM_CLASS_PATH, some, [CLASS], false]
    [CLASS_PATH, some, [SOURCE, CLASS], false]
    [PLATFORM_CLASS_PATH, some.pkg, [CLASS], false]
    [CLASS_PATH, some.pkg, [SOURCE, CLASS], false]
    

    I’m not sure how difficult it will be for your specific environment to create the appropriate Iterable<JavaFileObject> instances, but I think that’s what would be required…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to compile my java project in eclipse but I am at a
I have MinGW and I wish to compile the SQLite amalgamation source into a
i wish to connecting webservices in java using apache,axis2 and eclipse. here i got
I wish for a class A to contain some data, and class B will
I wish to get the current url minus the file name that is being
I'm a few days into learning Clojure and are having some teething problems, so
I wish to compile my asp.net MVC application using aspnet_compiler.exe from the comandline to
i have a small program that uses 32bit object file, and i wish to
I'm facing a tricky problem. I'd like to forge a C source file content
I wish to emulate an ARM architecture (I wish to compile software for my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.