# gjavac user guide

Because gjavac does not directly compile the Java/Kotlin source code into hvm bytecode, you need to install Jetbrains IDEA (there is a free community version) or Java SDK to compile the Java/Kotlin source code into Java bytecode files, and then use gjavac compiles Java bytecode files. Class files are converted to hvm bytecodes, Jetbrains IDEA is recommended

You can configure the development environment by following these steps:

  • Please follow Java SDK 8+ and configure the environment variables correctly
  1. Please install Jetbrains IDEA Community
  2. Create a new Java or Kotlin project and add several .jar files of gjavac to the "references" of the project. This project is used to write smart contracts or scripts on the chain. Ultimately, we are going to compile this project to hvm bytecode
  3. Referring to the example in the demo, DemoContract1.java and DemoContract.kt are examples of smart contracts. Modify the source code of the newly created project
  4. Create a new project that refers to the previous project under the same Java/Kotlin project. This project is used to debug and call smart contract Java/Kotlin code directly in Jetbrains IDEA. Set this project as the startup project of the solution
  5. In the project created in step 4, you can run the project to simulate and debug the smart contract
  6. Compile the entire project, find the .class files generated by this project in the target/classes or classes folder of the project created in step 2 (it may be different according to the IDE and project management methods)
  7. The execution gjavac class files -o result.assgenerates the hvm assembly file result.assand the contract meta information file result.meta.json, and then uses the hvm_assembler -g result.ass result.meta.jsonobtained result.gpcfile, which is the contract .gpc file of the target project
  8. Use the generated .gpc file for subsequent actions such as registering contracts, calling contracts, and registering scripts
  9. If the contract is not to write on the chain, but to execute code, it is necessary in step 7, the switchhvm_assembler -c result.ass result_meta.jsongenerates "result.out" file, which is hvm bytecode files, can then be used hvm file_path.outto execute the bytecodes directly file