I am trying to create an application that can compile a provided .java file during runtime. I understand that there is a programmatical compiler available within the tools.jar of the JDK. However, I cannot guarantee that the user of the application has JDK. I have attempted to package tools.jar within the application and reference it as a library. This seems to work within the Eclipse IDE when I have tools.jar added into the Bootstrap Entries of the classpath. When exporting the application to a runnable jar (with tools.jar packaged with it),
ToolProvider.getSystemJavaCompiler(); returns null. I am not exactly sure what the issue is, but I believe it may have to do with the Bootstrap Entries of the classpath not being properly preserved when the application is exported to a runnable jar. Any ideas? Are there any alternatives to the tools.jar compiler that I could use? Thanks for your patience, as this is my first question posted here!
How to use JavaCompiler from tools.jar without JDK
706 Views Asked by rgoulazian At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in ECLIPSE
- Set log4j.properties for GWT
- Compound classes stored in an array are not accessible in selenium java
- Eclipse color highlighting broken
- Eclipse Luna with Nodeclipse hangs when navigating a .js file with the Outline view
- Java Heap Space error on Layout xml: GC overhead limit exceeded
- Eclipse, how to find how many attributes defined in a class?
- Eclipse and Windows Headers
- Eclipse find source file from library
- mingw-64 conflicting declarations when cross-compiling
- String.split() not behaving in android
- local variable referenced before assignment in strange condition
- eclipse errors when try to change to master git branch
- Scala Eclipse IDE compiler giving errors until "clean" is run
- Not able to send email in java using SMTP,its blocked by firewall in my office.Is there any other method by which we can send mail?
- Behaviour Difference: Intellij vs Eclipse
Related Questions in CLASSPATH
- maven pom.xml dependencies order vs classpath/build path order
- Derby, Java: Trouble with "CREATE_TYPE" statement
- Can I use \ and / to be directory delimiter in CLASSPATH of .bat
- Java FrameDemo Error: Could not find or load main class
- How to set resources directory in eclipse dynamic web project?
- Absolute filesystem path for an IClasspathEntry
- Scala classpath not finding default package class in local directory
- NoClassDefFoundError with Kryo
- adobe pro cc (AS3) not recognizing box2d classpath
- Hadoop Job class not found
- when writing spock test in groovy java mixed project unable to resolve class
- Importtsv command gives : Container exited with a non-zero exit code 1 error
- WEKA API LibSVM ClassPath not found
- Non user specific path operations?
- Getting a List of files from a class path entry
Related Questions in JAVACOMPILER
- java.lang.NullPointerException when I use JavaCompiler to compile another class
- How to compile multiple java source files dynamically
- JavaCompiler cannot find symbol
- SecureClassLoader doesn't find depending interfaces
- Java: Compile code at runtime on a jre
- How to use JavaCompiler from tools.jar without JDK
- How do you create a JavaCompiler instance for a JDK not on your path?
- How to validate Java code programatically?
- Why the code that the compiler approves but cannot be run by JVM?
- Compile and Run java program in linux with path to the .java file and path to external jars
- Android databindingError:Cannot change dependencies of configuration ':mobileBanking:compile' after it has been resolved
- Compiling and running java project with many dependencies classes in other directories
- ToolProvider.getSystemJavaCompiler() returning null in JDK 9
- "Package Doesn't Exist" - Error if I try to include a JAR-File [java compiler]
- when invoking a java method by method.invoke() its not returning any value instead print in the console log
Related Questions in TOOLS.JAR
- Source code for "tools.jar" available under jdk1.6
- ToolProvider.getSystemJavaCompiler() always returning null using jdk
- How to activate a pom.xml iff the os is not of a given family (eg. mac)?
- App has encountered a problem. The archive C:/Program Files/Java/jre1.8.0_251/lib/tools.jar.jar which is referenced by the classpath does not exist
- Java source code modification in annotation processor
- resolving tools.jar in ivy
- "Unable to locate tools.jar" when running ant
- Provider sun.tools.attach.LinuxAttachProvider not found
- Old solution not working for missing Tools.jar while building Portico on Red hat Linux using apache ant
- Maven: Failed to resolve dependency: C:\Program Files\Java\lib\tools.jar
- Tools.jar is missing
- How to use JavaCompiler from tools.jar without JDK
- Where is tools.jar located?
- JNLP: tools.jar not in the classpath
- Unable to locate tools.jar for Java SE 14
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You need to use the compiler within "tools.jar"
will return the compiler from the jdk defined in the path variable, you can do this instead:
Or you can add tools.jar as a library at compile time
Or you can change System properties, but that leads to unexpected behaviors