File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to make exe file for my java program in Windows XP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to make exe file for my java program in Windows XP" Watch "How to make exe file for my java program in Windows XP" New topic
Author

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

Suraj Kumar Gupta
Greenhorn

Joined: Jul 13, 2012
Posts: 6
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

Joined: Oct 13, 2005
Posts: 38513
    
  23
Welcome to the Ranch

I presume you know about .jar files, and about setting an entry point?
Suraj Kumar Gupta
Greenhorn

Joined: Jul 13, 2012
Posts: 6
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

Joined: Oct 27, 2005
Posts: 19684
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38513
    
  23
I think Rob has answered your question
Suraj Kumar Gupta
Greenhorn

Joined: Jul 13, 2012
Posts: 6
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

Joined: Jul 13, 2012
Posts: 6
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

Joined: Jul 13, 2012
Posts: 6
Hi All,

Request you to kindly help me for this problem.

Many Thanks in advance !
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Jul 13, 2012
Posts: 6
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.
 
Don't get me started about those stupid light bulbs.
 
subject: How to make exe file for my java program in Windows XP