| Crates.io | java_decompiler_ollama |
| lib.rs | java_decompiler_ollama |
| version | 0.1.0 |
| created_at | 2025-01-01 06:23:20.667448+00 |
| updated_at | 2025-01-01 06:23:20.667448+00 |
| description | Java decompiler using Ollama and javap |
| homepage | |
| repository | https://github.com/roquess/java_decompiler_ollama |
| max_upload_size | |
| id | 1500625 |
| size | 49,592 |
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.
qwen2.5-coder model, but you can change this by setting the OLLAMA_MODEL environment variable.javap is available in your environment, as it is used to disassemble the .class files.Add the following dependency to your Cargo.toml:
[dependencies]
java_decompiler_ollama = "0.1.0"
Example: Fibonacci Class
public class Fibonacci {
public static void main(String[] args) {
int n = 30;
System.out.println("Fibonacci(" + n + ") = " + fibonacci(n));
}
public static int fibonacci(int n) {
if (n <= 1) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
javac Fibonacci.java
This will generate a Fibonacci.class file.
Place the Fibonacci.class file in the test/dataset/ directory of your Rust project.
cargo run --example basic -- test/dataset/Fibonacci.class
This command will disassemble the Fibonacci.class file and print the equivalent Java source code.
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).
This project is licensed under the MIT License. See the LICENSE file for details.