Hi all,

I have a question that , can we use java program as c++ program? Means, when we compile a c++ program we get a .exe file and we can run it anywhere or send to any one.
Is the same possible in Java? As I know java creates a .class bytecode. I am using NetBeans.

Thanks in advance for any consideration
G10

Recommended Answers

All 5 Replies

And no, you cannot run a compiled "exe" anywhere. You can run it anywhere that has the exact same OS and architecture as the machine it was compiled for. That is exactly what Java does (except that they also work with newer versions), except that the "OS and machine" for which it is compiled is the JVM. So, you can run it anywhere where there a JVM present of, at least, the same level for which it was compiled.

P.S. "double clicking" works to (which is what most "people" who ask this question are actually concerned with) by creating a jarfile, see the deployment tutorials.

thanks for the answer, so far that is right, but when I compile a java program in my NetBeans IDE I get notepad and .class file created. How can I run the same program (not the project only source file) and the .class file in unknown format!!
Please clarify me
again thanks

I seen something rather interesting about a month ago about cross compiling open source software that can take a java class file decompile it and then recompiling it in a foreign language specifically Objective C which is the language that iphone runs on.

Found it http://www.xmlvm.org/overview/ there's also a vid on youtube about it. It seems it could work for many different languages as well but it wouldn't work as well as a program that was natively writen in that language.

And all completely unnecessary.

Netbeans creates a jarfile, it is in the dist directory.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.