Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)22k · #10358

building-native-image

Skill này làm gì

Skill này hướng dẫn AI build ứng dụng Java bằng GraalVM Native Image, đặt tùy chọn build và sửa lỗi. Skill dành cho nhà phát triển muốn chương trình Java chạy dưới dạng một file thực thi native duy nhất.

Khi nào nên dùng

  • ✓Khi bạn cần biến một chương trình Java thành file thực thi native bằng GraalVM.
  • ✓Khi quá trình build Native Image hoặc ứng dụng sinh ra gặp lỗi reflection, JNI, tài nguyên hoặc proxy.
  • ✓Khi bạn muốn thay đổi tùy chọn build Native Image như classpath, tên đầu ra hoặc mức tối ưu.

Liên kết skill

https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/building-native-image/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/building-native-image/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Giúp tôi build ứng dụng Java thành file thực thi native bằng GraalVM Native Image.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI làm theo các bước biên dịch mã Java, chạy công cụ native-image và khởi động kết quả. Khi gặp lỗi, AI tra cứu tài liệu hướng dẫn về reflection, tài nguyên và serialization.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

​# Building Native Image

Prerequisites

  • Set JAVA_HOME to a GraalVM distribution if your Java program uses the Native Image SDK. If you do not know the path, ask the user to provide it. ​

Build and Run

  1. Compile your Java file with javac.
  2. Build the Native Image:
    $JAVA_HOME/bin/native-image <app-name>
    
  3. Run the resulting executable:
    ./app-name
    
  4. If Native Image cannot find your class file, set the classpath explicitly with the -cp option. ​

Troubleshooting

Reachability Metadata

If you encounter runtime errors related to reflection, JNI, resources, serialization, or dynamic proxies, consult references/reachability-metadata.md before attempting a fix. Use this reference for:

  • NoClassDefFoundError or MissingReflectionRegistrationError
  • MissingJNIRegistrationError
  • MissingResourceException (missing resource bundle)
  • Any user question about reflection, JNI, proxies, resources, resource bundles, or serialization in Native Image. ​

Native Image Options

To configure classpath, optimization level, output name, platform target, monitoring, or other CLI flags, see references/native-image-options.md.

Reference Files

Topic File
Native Image CLI options references/native-image-options.md
Missing reachability metadata references/reachability-metadata.md
Câu hỏi thường gặp

Tôi có cần cài GraalVM để dùng skill này không?

Có. Skill yêu cầu JAVA_HOME trỏ tới một bản phân phối GraalVM, và AI sẽ hỏi đường dẫn nếu không biết.

Skill giúp xử lý những loại lỗi nào?

Các lỗi như thiếu đăng ký reflection, thiếu đăng ký JNI và thiếu resource bundle.

Skill có giúp đổi tùy chọn build không?

Có. Skill có bảng tham chiếu các tùy chọn dòng lệnh của Native Image, gồm classpath, tên đầu ra, nền tảng đích và nhiều tùy chọn khác.

Chi tiết

Mô tả gốc của tác giả

Build and troubleshoot GraalVM Native Image applications. Use this skill to build Java applications with GraalVM Native Image, configure CLI options, or resolve build or runtime issues.

repo: oracle/graal

Độ phổ biến

Sao GitHub
22k
Vị trí xếp hạng
#10358
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự