Problem creating executable jar file in java

View previous topic View next topic Go down

User verified solution Problem creating executable jar file in java

Post by BIT0220-Iftekhar on Sun Jan 02, 2011 10:29 pm

I was informed of this problem by BIT0216-habib. But I myself got stuck to this too. The steps followed to make the jar file is shown in the images below. But it doesn't work. Where is the problem ?














Last edited by bit0220-Iftekhar on Tue Jan 04, 2011 2:46 am; edited 4 times in total (Reason for editing : image loading problem|topic title edited)
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Sun Jan 02, 2011 10:44 pm

First of all, you didn't define where are you loading the file. or What are you trying to achieve.
generally, when you say load the jar file, it means loading / adding a jar library in a project.

Anyway, I assume you are trying to create a jar file which is used to directly run your application.

If that's the case, then try using "runnable jar file" while exporting.
you may try this tutorial for details:
http://iitdu.forumsmotion.com/tutorials-f93/creating-jar-file-t509.htm?highlight=file

If this answer does not satisfy you, please provide answers to the questions asked in this post.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0216-Habib on Mon Jan 03, 2011 12:07 am

I have tried by this way but unexpectedly faced problem. I got an extractable file and after extracting i got to folder named calculator and META-INF. After open the folder i got: this.

what the problem may be??
avatar
BIT0216-Habib
Administrator-RC

Course(s) :
  • BIT

Blood Group : O+
Posts : 217
Points : 458

View user profile

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Mon Jan 03, 2011 12:09 am

Sighhhhhhh
First of all, you didn't define where are you loading the file. or What are you trying to achieve.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0220-Iftekhar on Mon Jan 03, 2011 12:25 am

BIT0122-Amit wrote:First of all, you didn't define where are you loading the file. or What are you trying to achieve.

I guess you have read the content of my post(Rolling Eyes), I wanted to create a jar file(actually created but may be it didn't load to anywhere) but the file didn't work when executed. Neutral
anyway, I am editing the topic title for better understanding. Very Happy
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Mon Jan 03, 2011 12:30 am

bit0220-Iftekhar wrote:
I guess you have read the content of my post, I wanted to create a jar file(actually created but may be it didn't load to anywhere) but the file didn't work when executed. Neutral

Congratulations, your guess is correct:| your post says:

The steps followed to make the jar file is shown in the images below. But it doesn't work

If you are thinking that a jar file is used only to execute java applications, you are wrong.

which is why, I said,

generally, when you say load the jar file, it means loading / adding a jar library in a project.
Because the title is after all, "jar file loading problem"

And now that you mentioned "executed", which is what I assumed you were intending to do, I previously said,


I assume you are trying to create a jar file which is used to directly run your application.

If that's the case, then try using "runnable jar file" while exporting.

you may try this tutorial for details:
http://iitdu.forumsmotion.com/tutorials-f93/creating-jar-file-t509.htm?highlight=file

If this answer does not satisfy you, please provide answers to the questions asked in this post.

here is a hint. Exporting as jar file, and exporting as runnable jar file are not same.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0216-Habib on Mon Jan 03, 2011 12:48 am

amit bhai, i tried by exporting as runnable jar file but faced problem.
please see my previous post.


Last edited by BIT0129-tabassum on Mon Jan 03, 2011 3:42 am; edited 1 time in total (Reason for editing : removed color. Don't use color in text please, it conflicts with the colored links. I was also confused whether the "runnable jar" is a link or colored text.)
avatar
BIT0216-Habib
Administrator-RC

Course(s) :
  • BIT

Blood Group : O+
Posts : 217
Points : 458

View user profile

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Mon Jan 03, 2011 12:50 am

well, "by this way" is very ambiguous.
Can you upload the jar file and share it here?
And please avoid using colours in post.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0216-Habib on Mon Jan 03, 2011 1:08 am

this is the folder i got.

this is the source code for you.(main class: ScientificCalculator)

please try by yourself.


Last edited by bit0216-habib on Mon Jan 03, 2011 1:11 am; edited 1 time in total (Reason for editing : added information)
avatar
BIT0216-Habib
Administrator-RC

Course(s) :
  • BIT

Blood Group : O+
Posts : 217
Points : 458

View user profile

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Mon Jan 03, 2011 1:18 am

your jar file is ok. I can execute it directly. Means the procedure you followed is correct. Probably the jar file is not being executed using java, rather being dealt as a archive.

here is a screenshot as proof of me executing it Very Happy



you can click on the thumbnail to get a bigger size of the image. (here is a hint: thumbnails help page load faster, thus creating faster response Razz )

Now, what is the problem you are facing?
You need to fix the file association of jar file.
Or, you can check using command line.

java -jar YourJarFile.jar


edit:

to fix jar file associations, you may check this link

http://iitdu.forumsmotion.com/t503-windows-software-jarfix?highlight=jarfix

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0216-Habib on Mon Jan 03, 2011 3:06 am

problem solved.

thanks amit bhai and iftekhar. rep++ to both amit bhai and iftekhar.

I request iftekhar to mark this topic as solved.
avatar
BIT0216-Habib
Administrator-RC

Course(s) :
  • BIT

Blood Group : O+
Posts : 217
Points : 458

View user profile

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Mon Jan 03, 2011 3:15 am

bit0216-habib wrote:problem solved.

thanks amit bhai and iftekhar. rep++ to both amit bhai and iftekhar.

I request iftekhar to mark this topic as solved.

but but.. you didn't mention how it was solved Neutral Neutral

Anyway, happy to know it is solved Very Happy Banana Dancing
Now, where is my treat? Hungry

edit: A better topic title is "Problem creating executable jar file in java".

Makes more sense you know Very Happy Not all Jar files are built to be executable. They can be used to create libraries or other things as well.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0216-Habib on Mon Jan 03, 2011 3:15 pm

JRE was installed in my pc but JDK was not installed. At that time the jar file not worked.
Then i install JDK and the jar file works. For my own interest i uninstalled JRE and downloaded the jarfix.exe (link given by amit bhai) and installed. then the jar file works.

But i can't understand what the main problem was??
avatar
BIT0216-Habib
Administrator-RC

Course(s) :
  • BIT

Blood Group : O+
Posts : 217
Points : 458

View user profile

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0220-Iftekhar on Mon Jan 03, 2011 5:06 pm

1. I'm giving rep++ both of you (thrice for amit bhai and once for habib Very Happy) for posting helpful feedbacks on my problem.

2. I'm again editing my topic title(Amit bhai once more suggests a better title Mad )

3. I was able to solve my problem after amit bhai said:

Anyway, I assume you are trying to create a jar file which is used to directly run your application.

If that's the case, then try using "runnable jar file" while exporting.
Finally I'm now in a different problem regarding jar file. I'm not sure whether to make it a different topic or discuss it here. Neutral
(there exists an old topic regarding my problem in this forum and I've gone through that, but it wasn't conclusive to me)

My problem is: How can I load images in jar file ?
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Mon Jan 03, 2011 11:14 pm

bit0216-habib wrote:JRE was installed in my pc but JDK was not installed. At that time the jar file not worked.
Then i install JDK and the jar file works. For my own interest i uninstalled JRE and downloaded the jarfix.exe (link given by amit bhai) and installed. then the jar file works.

But i can't understand what the main problem was??

Erm, you have some misconception about JRE, JDK, and jar I guess.

First of all, JDK is required to create the bytecode of the java program you write. Eclipse users are exception. Maybe eclipse has some internal library using which you can create the bytecode without installing JDK only having JRE. (I did it myself as well when I started using Ubuntu back then). You might've noticed that eclipse itself is a java application. It can not run if you do not have JDK, or JRE. JDK contains JRE within itself. Anyway, lets assume the normal case.
You can not create bytecode without JDK. Now what is a jar file? In short, it is an archive containing compressed files.
Now, meet runnable jar file. It includes class files (bytecode files) and a manifest file, which contains information about how to use these bytecodes, if it is executed in a java virtual machine, i.e. JRE.

JRE is required to run the bytecode. It can be a class file, or a jar file, or something else. So, to run the runnable jar file you created using eclipse, JRE is enough.

But in windows, file associations is a problematic thing. In normal circumstances, if you install JRE, the file association of jar file looks like this:

Code:
java -jar %u
(at least, that's what is at linux), so that when you double click on the runnable jar file, it gives a command like this:

Code:
java -jar YourJarFile.jar

BUT
if you install some extracting software, like winrar, peazip, or things like that, the file association changes, and when you double click on the jar file, the extracting software tries to open it, rather than JRE.

That's why I said, you should've tried executing the file using terminal/command prompt. when you are manually instructing the jre to execute the jar file, the extracting software will be neglected.

Anyway, when you installed JDK, the file association of Jar file was set to jre again. And you were able to execute it normally.

jarfix is a software which simply sets the jar file association in windows for jre, so that you can execute it.

bit0220-Iftekhar wrote:1. I'm giving rep++ both of you (thrice for amit bhai and once for habib Very Happy) for posting helpful feedbacks on my problem.

2. I'm again editing my topic title(Amit bhai once more suggests a better title Mad )

3. I was able to solve my problem after amit bhai said:

Anyway, I assume you are trying to create a jar file which is used to directly run your application.

If that's the case, then try using "runnable jar file" while exporting.
Finally I'm now in a different problem regarding jar file. I'm not sure whether to make it a different topic or discuss it here. Neutral
(there exists an old topic regarding my problem in this forum and I've gone through that, but it wasn't conclusive to me)

My problem is: How can I load images in jar file ?

I think Rokon started helping you in your topic?

And the better the topic title, the better the solution becomes. Smile You didn't mention the platform you were using, so I kinda guessed that you were in windows. (Similar windows lookalike themes are available for Ubuntu).

Anyway, good to see that Habib's problem is solved. I will leave Rokon to handle your problem Razz

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0216-Habib on Tue Jan 04, 2011 12:01 am

thanks amit bhai. rep++ for your explanation about JRE, JDK and jar file.
avatar
BIT0216-Habib
Administrator-RC

Course(s) :
  • BIT

Blood Group : O+
Posts : 217
Points : 458

View user profile

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0220-Iftekhar on Tue Jan 04, 2011 12:15 am

I think Rokon started helping you in your topic?
yes he has.

You didn't mention the platform you were using, so I kinda guessed that you were in windows. (Similar windows lookalike themes are available for Ubuntu).
Platform for what? I didn't get it.

but rep++ Amit bhai for your explanation.
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Tue Jan 04, 2011 12:43 am

When people say Platform, they generally mean Operating System :p

Thanks for giving me all those reputation points Clapping

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0220-Iftekhar on Tue Jan 04, 2011 12:52 am

bit0220-Iftekhar wrote:
Platform for what? I didn't get it.
bit0122-Amit wrote:
When people say Platform, they generally mean Operating System :p
You got it wrong then Wink
I asked you for what reason you wanted me to mention platform(operating system) ?
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0122-Amit on Tue Jan 04, 2011 1:09 am

bit0220-Iftekhar wrote:

You got it wrong then Wink
I asked you for what reason you wanted me to mention platform(operating system) ?

I got it wrong because I got the correct meaning of your incorrect statement. Or rather, incorrect way of putting your statement. A better one was, Platform for what reason?

I do not see the reason for making that part bold, because I can and always do give emphasis to each part of a reply.

Anyway, you should've mentioned the operating system, because if your problem was with file association (Same as Habib's ) then the solution would've been quite different, as well as the procedure of finding out where the problem was. The problem could have been caused by several other types of OS related issues as well.

Your problem was not exactly a programming problem, rather it was a problem related to execution. It could've been a programming problem though. But if you can run it in your IDE, then it means it didn't have execution problem related to programming in a normal scenario. Rather, the problem was in creating the execution / conducting the execution.:p In such cases, information such as

-> Operating System
-> Program used to create the execution file and its version / how the file was collected if you didn't create it.

And other related issues are generally necessary.

Anyway, it was your problem, and we, who are trying to help you, couldn't even see what did you do in your computer when you faced that problem. The screenshots are okay to demonstrate what you did exactly at the point of creating the software. But these do not cover the whole story.

Giving out details means you are helping yourself. Because the more details you give, the more easier it becomes for us to solve it.

If you decide to simply state the problem you are facing, without giving out details, and start asking why the person who was trying to help you wanted details, I doubt he will be in a helping mood anymore.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by BIT0220-Iftekhar on Tue Jan 04, 2011 2:45 am

খাইছে!
একটা ছোট্ট বিনয়াবনত প্রশ্নের এত লম্বা উত্তর Very Happy
যাই হোক,উত্তরের যথার্থতা নিয়ে আমার সন্দেহ নেই;ভবিষ্যতে আরও বোধগম্য পোস্ট প্রদানের অঙ্গীকার করছি।
আর টপিকটি solved আইকন চিহ্নিত করছি।
avatar
BIT0220-Iftekhar
Administrator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 434
Points : 630

View user profile http://iftekharunplugged.blogspot.com

Back to top Go down

User verified solution Re: Problem creating executable jar file in java

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum