Sign in to follow this  
Zyndrof

Executing Java-code?

Recommended Posts

It seems very complicated to execute Java-code and create .exe-files. Isn't there an easier way? Since I'm using an IDE (Netbeans 5.0) that's able to compile my code, shouldn't it be able to execute it too?

Share this post


Link to post
Share on other sites
java uses a byte code and doesn't naturally create machine code exes. but you can use third party programs such as: http://www.thisiscool.com/gcc_mingw.htm to make exes that store javas virtual machine inside them with a slight overhead

Share this post


Link to post
Share on other sites
So you're saying, that on the command line, this:

>MyApp.exe

Is much more complicated than this:

>java MyApp

I don't know about Netbeans, but Eclipse has a console from which you can run your programs. As for turning programs into .exe's - in Java you turn them into executable jar files.

If you get stuck post in this thread, and I'll try and help you out.

Jon

Share this post


Link to post
Share on other sites
Quote:
Original post by bgilb
java uses a byte code and doesn't naturally create machine code exes. but you can use third party programs such as: http://www.thisiscool.com/gcc_mingw.htm to make exes that store javas virtual machine inside them with a slight overhead


If that's the case, shouldn't Java have a format that suits it and will start the program without you having to use the command window?

Share this post


Link to post
Share on other sites
Quote:
If that's the case, shouldn't Java have a format that suits it and will start the program without you having to use the command window?


it does. jar files like polly said.

Share this post


Link to post
Share on other sites
Quote:
Original post by pkelly83
If JRE is set up right double clicking on an executable jar file should run it. Unfortunately some mobile phone software interferes with this set up, Nokia PC Suite in particular.


I see :)

It just seems like so many steps to create a .jar file :/

Share this post


Link to post
Share on other sites
But thats a problem for programmers; not end users. Read the link I posted, it's really not that hard, and will probably take you less time than you think.

You just have to create a manifest file saying in which class your main method is, jar it up with your class files, and thats it.

Jon

Share this post


Link to post
Share on other sites
Quote:
Original post by polly
But thats a problem for programmers; not end users. Read the link I posted, it's really not that hard, and will probably take you less time than you think.

You just have to create a manifest file saying in which class your main method is, jar it up with your class files, and thats it.

Jon


Okay, thank you!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by bgilb
its not about being more complicated its about whats more convient for the end user and sadly lots of people have no clue what a jar file is.


YEs and not every1 wants to download a *** sdk to run java... or a virtual machine or whatever

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
YEs and not every1 wants to download a *** sdk to run java... or a virtual machine or whatever


right, but that's the whole point of Java and what makes it platform independent. It _cannot_ run without a virtual machine. Windows comes with a built in JVM. As previously mentioned if you don't want your users to suffer potential hassle, do the leg work and make your java app an EXE: but then you've just lost the biggest benefit of Java because now only windows users can run your app.

-me

Share this post


Link to post
Share on other sites
Eclipse has a wizard that can create JAR files in seconds. JAR files are just ZIP files with a MANIFEST file(thats a text file) and META-INF directory stuck in to tell it what class to run, you can make them with winzip too. Look what [Google] gives you everything you want to know about JAR files!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this