• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

could not find the main class

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm trying to make a workable jar with ant:

here's my (relevant) dir structure:
here's my manifest from inside my jar:

what am i doing wrong?

TiA
[ April 01, 2006: Message edited by: miguel lisboa ]
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try putting the main-class path in your Manifest as
projc.bin.giu.GuiLogin
[ April 03, 2006: Message edited by: Pratik Lohia ]
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To Pratik Lohia

I don't think your answer is correct unless those top packages are defined in the package statement.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To miguel lisboa

I think you might not packaged your class files in your jar, see this line


Try to open your jar to see what are inside.

Thanks!
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roseanne: i checked and they are all there
using the same ant script i can perfectly run my app:

as you can see i invoque my main class twice (for running and for jar) the same way

i tried several combinations, with and without explicit manifest file, and with manifest at several locations...
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you double click your jar in windows, does it run?

If it does not, then hand change to make it run, then you will probably find out your problem.

From my experiences, if you can make something work by your hand, then you know how to make it work by ant.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi again Roseanne: thanks for helping

i'm not sure if i understood you right
my jar doesnt open, instead says cant find main class - and that's the reason i'm posting here

If it does not, then hand change to make it run



do you mean creating a jar from command line? and then compare paths and manifest?
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by miguel lisboa:

do you mean creating a jar from command line? and then compare paths and manifest?[/QB]



That is one way to do it for sure.

Another way is creating a simple enough project with one HelloWorld.java, make your build file work on that one. You eliminate all the complexity and distractions. Focus on one thing and one thing only.

I always believe, you can do it by hand, then you can do it by using ant.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks again

my swing app is a standalone java app that interacts with database using hibernate, so i need several jars to have my app working

i developed all this using eclipse; here i added the packages (org, com, javax, etc) into my project and this way i can create an executable jar using eclipse wizard.

i also manually created an executable jar adding those jars to manifest classpath, but i had to have all those jars allways next to my jar, in order to have it working (didnt like this solution)

next, i tried to (re)create my proj, in another location, using jars instead of packages (inside lib folder):
<property name = "librarydir" value = "${basedir}/lib" />

<path id = "libraries">

<fileset dir ="${librarydir}">

<include name = "*.jar" />

</fileset>

</path>

and building and running it with ant: success!
the problem appeared when i tried to generate the dreaded jar

now, i tried using command line and coud not get the jar, because of the same error msg; so i added the several needed packages (instead of jars), and got it working, using:
C:\javas\projc\bin>jar -cmf MANIFEST.MF CDC.jar bd creditacao dominio excepcoes gui hbm io negocio org test util hibernate.cfg.xml log4j.properties img net com javax

now i guess that is impossible to create an executable jar from a project that itself includes jar files...

at this moment i'm looking at something called "one-jar", suposedly created for situations such as mine

as an aside, you might have noticed i'm no pro, just a java amateur who uses java for fun (in my spare time)
 
reply
    Bookmark Topic Watch Topic
  • New Topic