Java Decompiler Ollama
This Rust library provides functionality to disassemble Java class files using javap
and translate the bytecode to equivalent Java source code using the Ollama API.
Requirements
- Ollama: Ensure that the Ollama API is accessible. By default, the library uses the
qwen2.5-coder
model, but you can change this by setting theOLLAMA_MODEL
environment variable. - Java Development Kit (JDK): Ensure that
javap
is available in your environment, as it is used to disassemble the.class
files.
Installation
Add the following dependency to your Cargo.toml
:
[]
= "0.1.0"
Usage
Example: Fibonacci Class
Create a Java class file: Save the following Java code in a file named Fibonacci.java:
Compile the Java class:
This will generate a Fibonacci.class file.
Place the Fibonacci.class file in the test/dataset/ directory of your Rust project.
Run the Rust example:
This command will disassemble the Fibonacci.class file and print the equivalent Java source code.
Environment Variables
You can customize the behavior of the library by setting the following environment variables:
OLLAMA_MODEL: The Ollama model to use for translation (default: qwen2.5-coder).
OLLAMA_URL: The URL of the Ollama API (default: http://localhost:11434/api/generate).
License
This project is licensed under the MIT License. See the LICENSE file for details.