5 Replies - 4650 Views - Last Post: 28 January 2012 - 03:03 PM Rate Topic: -----

#1 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

How to convert a code to .exe file?

Posted 28 January 2012 - 07:02 AM

Hi all,

I've written code in java, and now I want to convert it to an exe file, so by just double clicking on it the code be implemented, but I don't know how.would you please help me with it.

Thanks in advance.
Sophia
Is This A Good Question/Topic? 0
  • +

Replies To: How to convert a code to .exe file?

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: How to convert a code to .exe file?

Posted 28 January 2012 - 07:08 AM

Export the project to a runnable .jar file that can be run on any computer that has the JRE installed. The export can be accomplished quite easily using more capable IDEs or other programmer's editors with appropriate scripts installed as plugins or however they do it. If you're programming from the command line using simple editors without these capabilities built in or yet added, then research "export to runnable jar" for your specific development environment. We'll provide more help as needed, but let us know which method of exporting the .jar file you'll use so we know what help you need.

No matter which method you choose, you may find the discussion here helpful to understand what's going on. I believe there are also tutorials here on DIC that discuss exporting a project to a .jar file.

This post has been edited by GregBrannon: 28 January 2012 - 07:13 AM

Was This Post Helpful? 1
  • +
  • -

#3 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: How to convert a code to .exe file?

Posted 28 January 2012 - 08:56 AM

View PostGregBrannon, on 28 January 2012 - 05:38 PM, said:

Export the project to a runnable .jar file that can be run on any computer that has the JRE installed. The export can be accomplished quite easily using more capable IDEs or other programmer's editors with appropriate scripts installed as plugins or however they do it. If you're programming from the command line using simple editors without these capabilities built in or yet added, then research "export to runnable jar" for your specific development environment. We'll provide more help as needed, but let us know which method of exporting the .jar file you'll use so we know what help you need.

No matter which method you choose, you may find the discussion here helpful to understand what's going on. I believe there are also tutorials here on DIC that discuss exporting a project to a .jar file.

Thanks for your help.
Yes, I use Notepad and run the code in command prompt.
I saw the link you've mentioned, but I don't know why, when I run the Executable jar file it keeps giving me this error :
Failed to load Main_Class manifest attribute from
Was This Post Helpful? 0
  • +
  • -

#4 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: How to convert a code to .exe file?

Posted 28 January 2012 - 09:31 AM

This is one of the more difficult and frustrating problems to help someone with, because so much of what happens is dependent upon the respective user's development environment, and it seems no two development environments are alike.

An approach I recommend is to work step-by-step through a tutorial with simple example code and clear instructions that you can apply to your own project that might be more complicated. Once you get through the easy case - hopefully, getting it done correctly - you'll have worked through the basics. You'll likely discover less basic potholes when you move to your own project, but you'll be better prepared to face them.

This tutorial seems to applicable to your situation. Review it, work through it, and you may discover the source of and solution for your problem(s).

Let us know how it goes.
Was This Post Helpful? 1
  • +
  • -

#5 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: How to convert a code to .exe file?

Posted 28 January 2012 - 11:41 AM

View PostGregBrannon, on 28 January 2012 - 08:01 PM, said:

This is one of the more difficult and frustrating problems to help someone with, because so much of what happens is dependent upon the respective user's development environment, and it seems no two development environments are alike.

An approach I recommend is to work step-by-step through a tutorial with simple example code and clear instructions that you can apply to your own project that might be more complicated. Once you get through the easy case - hopefully, getting it done correctly - you'll have worked through the basics. You'll likely discover less basic potholes when you move to your own project, but you'll be better prepared to face them.

This tutorial seems to applicable to your situation. Review it, work through it, and you may discover the source of and solution for your problem(s).

Let us know how it goes.



Thanks again Greg. The tutorial was great but still there is a problem.
I've done all the steps that's been written in that tutorial (step by step) , and my code is a GUI, but when I double click on the Executable jar file I have this error :

Quote

Could not find the main class: MyMainClass. Program will exit.

And when I try to run the jar file from the command prompt I have this error :

Quote

Unable to access jarfile MyJarFile.jar

I'm sure about the MyManifest text file, but I dunno what's wrong.
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2718
  • View blog
  • Posts: 11,431
  • Joined: 20-September 08

Re: How to convert a code to .exe file?

Posted 28 January 2012 - 03:03 PM

Firstly please post the listing of the jar

jar tf <the name of the jar here (no angle brackets)>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1