Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make exe file for my java program in Windows XP

 
Suraj Kumar Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I have made a program which includes a few classes (around 3-4).
Currently I have made a BATCH file which runs at scheduled time for the task to complete which is running in my system.

Summary of my program:
The program has been created to connect Database (Oracle) of some application and execute a query.
Based on the query result it sends mail to the responsible.


I want to make an exe file for my program so that I can share that with my colleagues instead of scheduling the same on everyone's system.

Kindly help me on how to proceed with this.

I am a user of Windows Xp

 
Campbell Ritchie
Sheriff
Pie
Posts: 49447
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I presume you know about .jar files, and about setting an entry point?
 
Suraj Kumar Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell ,

Thanks a lot for the welcome.

Yes I know about jar files and know how to create them but not sure what you mean by setting an entry point ?
Are you talking about the customized Manifest file with the attribute Main-Class to be used while creating the jar-file ? If you are talking about something else then please explain it.
I have also made 2 jar files ( 1 general one (DLALL.jar) and other using attribute Main-Class (RDL.jar)).
When i try running the 2nd jar file (RDL.jar) using the command "java -jar RDL.jar" through command prompt from the directory in which the RDL.jar is present i get the below exception:


Kindly guide me further
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the Main-Class attribute is set to DeadlockControllerAll.class. It should be set to DeadlockControllerAll, as that's the class name. Assuming it's in the default package of course, otherwise the package name would have to be part of the class name.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49447
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Rob has answered your question
 
Suraj Kumar Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob & Campbell !

Yes, that was my mistake but after correcting that I am getting new error.
Actually my jar file (RDL.jar) includes 2 other jar files namely - mail.jar & ojdbc14.jar and i think i m missing something related to addition of other jar files while making my new jar.
Below is the error:


Manifest file of my jar(RDL.jar)


Kindly advise the needful.
Thanks in advance !
 
Suraj Kumar Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am able to run my so called first jar (RDL.jar).

I understood now on how to add other jar files into my jar file using the "Class-Path" header value in my customized Manifest file.

After creation of the jar it runs fine in my system BUT when i give the same jar file to one of my friend he is not able to run it.
The same exception (Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
) which I posted in my previous post is arising.
Note: I have given exactly the same jar file ,which includes other 2 jar files,to my friend which is running absolutely fine in my system

Kindly provide a Hint for this cause .

Thanks in advance.
 
Suraj Kumar Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Request you to kindly help me for this problem.

Many Thanks in advance !
 
Paul Clapham
Sheriff
Posts: 21142
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be assuming that including a jar file inside your executable jar automatically puts that included jar file into the classpath. It doesn't (as the error message quite clearly indicates).

The way do to this (and I'm pretty certain that the JAR tutorial tells you this) is to put a "Class-Path" entry in the manifest, and list the other jar files in that entry. Note that you put the path to those other jar files relative to the executable jar; the easiest way to manage that is to have the other jars in the same folder as the executable jar.
 
Suraj Kumar Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks !
In my previous post I have stated about the user of "Class-Path" attribute in Manifest file but i was not placing other jar files in the same folder as the executable jar.

As per your suggestion after placing the other jars in the same folder I am able to run the jar in other machine also.

I would be happy to know if there is another way by which I can avoid the jars to be put again in the same folder which are already present in my executable jar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic