• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To convert a console based Eclipse project to JAR ?

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a simple console based java program that takes some user input, creates a file, fills it with text and also displays the text filled.
I want to make this into something like an exe. So, I made it into a JAR and tried to run it. But, this caused an error
message(please see attached image). Why does this error occur and how do is solve it ?
Please also tell me why does such a program not invoke the console automatically ?

Thanks.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see any attached image.

But don't try to fix that by attaching an image, just copy and paste the error message for us to read.

As for why your code doesn't use the console, that would be because you ran it using java.exe instead of javaw.exe (or vice versa -- I don't remember which has a console because I haven't ever written a console app in Java).
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I don't see any attached image.

But don't try to fix that by attaching an image, just copy and paste the error message for us to read.

As for why your code doesn't use the console, that would be because you ran it using java.exe instead of javaw.exe (or vice versa -- I don't remember which has a console because I haven't ever written a console app in Java).



I put the image instead to save the typing. How do I make my code use Javaw instead and run like an exe file ?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

justin smythhe wrote:I put the image instead to save the typing.


Translation: I'm not going to do any work to make my question easier to answer by the volunteers at this site.

Not a winning strategy.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

justin smythhe wrote:I put the image instead to save the typing.


Translation: I'm not going to do any work to make my question easier to answer by the volunteers at this site.

Not a winning strategy.



That's not what I meant.
Here is the message -
Failed to load Main-Class manifest attribute from C:\Temp\AnalysisOfCVSjar.jar

I don't know how typing the error would be better than posting the image.

Thanks.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

justin smythhe wrote:I don't know how typing the error would be better than posting the image.



It's because reading a short piece of text takes a fraction of a second whereas the image alternative requires me to see a blurry blob, click on it, and wait several seconds for another application to open up and display it. That's if I assumed the image was safe (safe for work, not a malware carrier, and so on). Summary: text is easy, image is a nuisance.

Anyway the error message says you haven't built your jar correctly. It doesn't have a Main-Class attribute in the manifest (as the message says) and therefore it isn't an executable jar. So java.exe versus javaw.exe doesn't come into the picture.
 
justin smythhe
Ranch Hand
Posts: 107
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:
Anyway the error message says you haven't built your jar correctly. It doesn't have a Main-Class attribute in the manifest (as the message says) and therefore it isn't an executable jar. So java.exe versus javaw.exe doesn't come into the picture.



Thanks for the info. I am now trying to make it work. Putting a link below for everyone to refer to:
Setting an application's entry point



 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you've got hold of the right tutorial. Carry on then, let us know how it goes.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Looks like you've got hold of the right tutorial. Carry on then, let us know how it goes.



What i learned from the above link:

If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application's entry point. You provide this information with the Main-Class header in the manifest, which has the general form:

Main-Class: classname

The value classname is the name of the class that is your application's entry point.

Recall that the entry point is a class having a method with signature public static void main(String[] args).



Then, I used the tutorial below and tried to make a manifest file for my eclipse project. But it failed.
When I run the jar, i get an error - Could not find the main class: com.doIT.TestJar
Add a manifest file to project in Eclipse - Tutorial

btw, i unzipped this jar to see the contents. It has a manifest folder with manifest file and also my eclipse settings and other folders.

How, do I get this thing to work ?

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

justin smythhe wrote:When I run the jar, i get an error - Could not find the main class: com.doIT.TestJar
Add a manifest file to project in Eclipse - Tutorial

btw, i unzipped this jar to see the contents. It has a manifest folder with manifest file and also my eclipse settings and other folders.

How, do I get this thing to work ?



Doesn't the error message suggest anything to you?

It says it couldn't find your main class. So is that class in the jar? (Hint: the error message says it isn't.) There should be a folder named "com" at the root of the jar, and it should contain a folder named "doIT", which in turn should contain your TestJar.class.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

justin smythhe wrote:When I run the jar, i get an error - Could not find the main class: com.doIT.TestJar
Add a manifest file to project in Eclipse - Tutorial

btw, i unzipped this jar to see the contents. It has a manifest folder with manifest file and also my eclipse settings and other folders.

How, do I get this thing to work ?



Doesn't the error message suggest anything to you?

It says it couldn't find your main class. So is that class in the jar? (Hint: the error message says it isn't.) There should be a folder named "com" at the root of the jar, and it should contain a folder named "doIT", which in turn should contain your TestJar.class.



It seems that I have to create a folder with the class files. I tried using this link to get the job done.
However, in the final step of making my jar, i see an option to choose the class with main method. It shows me the src folder and not the classes folder to select my class from.
According to what I read, eclipse creates a bin folder to put your classes into. This has created new doubts:
1- Can't I give it another name instead of bin ?
2- I don't know why I can't see the bin folder inside eclipse. But, I can see it by manually looking into the project folder.

Please help me. I feel I am close to the end.



 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where is your code? what type of error you are getting?
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

BalaMurali dhar wrote:where is your code? what type of error you are getting?



Please tell me why the code needs to be posted for this issue.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me move this thread to the IDEs forum, since it seems to be entirely about how to do something in Eclipse.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

justin smythhe wrote:Please tell me why the code needs to be posted for this issue.


Because without seeing your project's structure, the code in question, and the full and complete error message, all we are doing is guessing. Which is fine if all you want is general suggestions on things to look at. But if you want a definitive solution for the problem you have run the more concrete information you can supply, the better.

You could provide the following:
1) A screen shot of the Eclipse project, with the Project Explorer view fully expanded so that all of your source files show up. (It is best to click the screen shot so that only the Project View show, don't send a full monitor shot)
2) The source code for the main class (the class with the main method, copy and pats this as text)
3) The full error message that you are seeing. I assume the error is in the Console view - copy and past the text into the post.
 
What's brown and sticky? ... a stick. Or a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic