473,499 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compile a java program into real machine code.

myusernotyours
188 New Member
hi all, I'd like to know whether it's possible to compile a java program into actual machine code so that the program runs without the need for the Java Runtime.
If it's possible how can it be done?

Thanks in advance.
Dec 7 '07 #1
2 1672
JosAH
11,448 Recognized Expert MVP
hi all, I'd like to know whether it's possible to compile a java program into actual machine code so that the program runs without the need for the Java Runtime.
If it's possible how can it be done?

Thanks in advance.
Your Java bytecode *is* compiled to real machine code but you need the virtual
machine (JVM) for it. It's the JIT (Just In Time) compiler that does the job. It is
fired up by the HotSpot mechanism that checks if a piece of code is executed
more than once; if so, the byte code is transformed to the machine code of the
native platform.

There is no need to attempt to transform the byte code of the entire JRE (all the
core classes etc.) to machine code; the resulting executable file will be huge
which you don't want.

kind regards,

Jos
Dec 7 '07 #2
Nepomuk
3,112 Recognized Expert Specialist
hi all, I'd like to know whether it's possible to compile a java program into actual machine code so that the program runs without the need for the Java Runtime.
If it's possible how can it be done?

Thanks in advance.
Hi!
If what you're attempting is, to have an executable which will run on a system without the JRE, there are possibilities. However, your program will loose platform-independence and might become slower.

For Windows systems for example, just search the web for "jar to exe" or similar. Then all you'll have to do is create a jar-file of your program and use the software found by that search to create an executable file from it.

Depending on your code, a cross-compiler might be another solution - if you have it translated for example to C++ (or C for that matter), you could compile it to an executable directly. However this will not work in all cases and you'd possibly be better of with either using the above method or rewriting your program in a different language (that is, if you really want to do without the JRE).

Greetings,
Nepomuk
Dec 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3380
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
198
18081
by: Michael N. Christoff | last post by:
Java, the software developed by Sun Microsystems in the mid-1990s as a universal operating system for Internet applications, gave NASA a low-cost and easy-to-use option for running Spirit, the...
23
3621
by: BlackHawke | last post by:
Hello! This is my second post. Ppl really helped me with the first. I hope there are answers for this one as well I own a game company (www.aepoxgames.net) releasing the beta for our first...
114
9685
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
11
9208
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
9
4274
by: dalewz | last post by:
Hi, I know that java can run on any machine. And C# is competing with java. I just came back from book store. I found that none of C# books state that its application can run everywhere. I am...
133
8423
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
17
3095
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
1
9582
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.