1

When compiling a '.java' file it will create a new '.class' file, which is not a pure binary file. To run this file you need an interpreter called 'java'. Is there a way to convert this '.class' file to a binary file? In which you don't need another program to run?

F.ex './filename' in Linux.

Sorry for my bad english.

-Henrik

  • 2
    FYI, the program you're looking for is called a compiler :) Both the act of compiling .java to .class and compiling to a binary format are compilation (as is any machine-transformation of code). Also, "binary file" may be more correctly described as an "executable file" or perhaps something involving the phrase "machine language". – rmeador Sep 29 '09 at 23:08
  • Dup of http://stackoverflow.com/questions/804466/how-do-i-create-executable-java-program and http://stackoverflow.com/questions/80105/whats-the-best-way-to-distribute-java-applications – skaffman Sep 29 '09 at 23:17

1 Answers1

5

What you need is GCJ,

http://gcc.gnu.org/java/

ZZ Coder
  • 74,484
  • 29
  • 137
  • 169
  • I'm sure there are other possible solutions, but this is one, and seemingly a good one (I've used programs compiled with it, but never created one myself). +1 – rmeador Sep 29 '09 at 23:05
  • I am afraid that gcj isn't being maintained anymore. It's a pity. – Raul Luna May 15 '21 at 15:01