jar file problem , please help

Hi guys , i am not sure if i am in the right place to have this post in so i'll give it a try

i know my explanation might be a shot in the dark but i'll try my best

-

i have made a program using eclips , to send emails using my email , on certain conditions

so when that codition happenes on some class in my program

this class will call the email class and send an email to someone

now the problem is not in the program , because as along as this program is in eclips and i run the program in eclips , everything goes fine , No errors what so ever

but , if i make jar file , using eclips "export"

once i run the program , the program would run , but once the same condition that ihave specified previously happenes , the current class never calls the email class , and no emails would be sent

i am very confused wether

1) it throws a class not found for some wierd reason

2) or the external library that i used to send emails , is not exported

i tried to check the CLASSPATH file and i think everything seems to be fine , so i dont know what the problem is

so in short

if the program is in eclips , every thign goes fine

if the program is a jar file , then it would work fine but once it needs to send an email , it never does and i can still work on the program , but no emails will be sent

thanks please some one help me out with this

[1442 byte] By [--CoolK--a] at [2007-11-26 19:14:56]
# 1
I would bet it is throwing an error somewhere. Does nothing print on the console? Are you ignoring any of the exceptions you catch? The class path is set in the jar's manifest right? http://java.sun.com/docs/books/tutorial/deployment/jar/index.html
zadoka at 2007-7-9 21:16:28 > top of Java-index,Desktop,Developing for the Desktop...
# 2

you know this is the problem , the jar's manifest has a classphath file and i do check inside and its there

it does not complain AT ALL , the program keeps on running and everything but once it comes to sending email , it just does not

i have tried to do one test to see , weather the class works but it doesnt send emails or it does not work at all

what i did is that , i switched my main with the class where it sends emails

and i created a jar file based on that , what happened is the following

the jar file never works , which means , as u said somethign goes wrong and ihave no idea what goes wrong beccause everything is included

its soo wierd this problem ,

and i do agree with u , something is thrown some where and i am sure that i cought all kinds of exceptions

so i am not sure what elese should i catch to knwo whats going on

--CoolK--a at 2007-7-9 21:16:28 > top of Java-index,Desktop,Developing for the Desktop...
# 3
How are you running the jar file? At the command line?
zadoka at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 4

We need some more specific information to be able to help you.

- how are you trying to run your application, when no in Eclipse?

- what OS are you running on?

- is the class the can not be found one of yours, or one you depend on?

- if is one of yours do a 'jar -tf jarname.jar' (replace jarname.jar with the path to yours) and see if your class is in there

EDIT: If there is a classpath in the manifest, then the JARs need to be in the same folder as the current JAR. Paths are relative. BTW If you are willing to send me your program, with the dependencies, then I would happily take a look. Contact me ina private message.

ajmasxa at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 5

1) i am running my jar file on windows xp

2) how do i run it? i just click on it and it runs

3) the class that can not be found

( IF THE PROBLEM IS CLASSNOT FOUND because i dont know)

is one of mine and this class depends on a an externa jar file

so i dont know wether it complains about my class or the external jar file

4) i cant use the command line i am using windows

to check out my files i run my jar file using winrar to see whatever is includedand the classpath and manifest

i hope this helps

--CoolK--a at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 6

for more information here is the senario

because i see that you guys are some how lost because i am not providing enough information

so this is a detailed info of the problem

i have 3 classes

1) mybankmain (jframe)

2) mybankbody(all labels and buttons and events included here)

now: within some events in my program ,

it calls a class called.....

3) myEmail

this class imports two things that are comming from an external jar file , so in short , if the external jar file is not available the program would complain

i run this on windows xp (SP2)

now: if this program runs on eclips , it would do everything it is supposed to do and all kind of calculations will be done and emails will be sent on the conditions that i have specified within the program

if i make a jar file on windows , and i run the jar file , the file would work , all functionalities will work

EXCEPT: sending an email

- either my class is not found

- or external jar file is not found which causes my class not to be able to perform its tasks

i did only one test

which is that i switched the main and i made myEmail as a main and i tried to export the jar file

Result: jar file doesnt work

the way i view whatever inside my jar file , i use Winrar and it would view everythign in the jar file and i see that all my classes are included there

if i open my CLASSPATH , i see that there is a pointer to the external jar file

if i open my manifest : i DO NOT see the exrernal jar file in there but i do see that its pointing to my main class

class main : mybankmain

and there is only the version and signiture

i hope all these additional details would help in determining the problem that ihave been trying to solve for 2 weeks now

--CoolK--a at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 7
> 4) i cant use the command line i am using windows Click Start then Run.Type cmd and hit enter.Then run the Jar and see if there is any output.
zadoka at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 8

non no outputs throughout cmd

i went to the file location and i printed name.jar

when i run it , it just runs successfully with no complains

but if i use this command jar -tf name.jar

it just complains about jar not being a command , so i cant run it

thats all i get

--CoolK--a at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 9

> non no outputs throughout cmd

>

> i went to the file location and i printed name.jar

>

> when i run it , it just runs successfully with no

> complains

So it works fine? Does it send the email?

So it works in eclipse and on the command line, but not when you double-click on it?

>

> but if i use this command jar -tf name.jar

>

> it just complains about jar not being a command , so

> i cant run it

> thats all i get

zadoka at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 10

i am very sorry but its really disappointing

no it doesnt send an email on the command line ,

when i said it works , i ment as in there are no complains , but it doesnt send an email , its soo wierd this and i am really about to give up and just use eclips

everytime i wanna use this program

--CoolK--a at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 11

> i am very sorry but its really disappointing

>

> no it doesnt send an email on the command line ,

>

> when i said it works , i ment as in there are no

> complains , but it doesnt send an email , its soo

> wierd this and i am really about to give up and just

> use eclips

> everytime i wanna use this program

Add some printlns before and after the email sending. So you can see if there is an exception or if it runs fine but the email isn't being sent.

zadoka at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 12

i have done that and guess what

here is the senario

}

blah blah

.

.

. <<< it prints this

blah.emailclass(parameters) <<< stops here

}

so it never actually calls that class

or it does but it cant perform anything cause it contains error , as in all the imports in the email class are coming from an external library

--CoolK--a at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 13

> so it never actually calls that class

>

> or it does but it cant perform anything cause it

> contains error , as in all the imports in the email

> class are coming from an external library

Put a try{ catch{ around it and catch Throwable and printout what you find.

zadoka at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 14

s = JOptionPane.showInputDialog(" Please Specify The Reason of this transaction ");

message = message + s +"\n\nFor Any Additional Information Regarding your Account contact\n"+

"zero@gmail.com\n\n"+"Regards\nK.";

// i put a print over here and it works i mean it does whats supposed

//to do

SmtpGmail E = new SmtpGmail (message);

//i put a print over here , it doesnt display it , which means

// creating object E of type smtpGmail has faild because it doesnt even get to this point

E.email();

JOptionPane.showMessageDialog(null, "An identification Email Has been sent to\n"+"blah@hotmail.com");

--CoolK--a at 2007-7-9 21:16:29 > top of Java-index,Desktop,Developing for the Desktop...
# 15
one second let me try that
--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 16

java is playing fool or i dont know how to use java

try{

SmtpGmail E = new SmtpGmail (message);

E.email();

JOptionPane.showMessageDialog(null, "An identification Email Has been sent to\n"+"blah@hotmail.com");

throw new Myexception();

}catch (Myexception e){

JOptionPane.showMessageDialog(null, e);

}

it doesnt send an email and it doesnt throw any exceptions

--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 17

> java is playing fool or i dont know how to use java

>

> try{

> SmtpGmail E = new SmtpGmail

> (message);

>E.email();

> JOptionPane.showMessageDialog(null, "An

> identification Email Has been sent

> to\n"+"blah@hotmail.com");

>throw new Myexception();

> }catch (Myexception e){

>

>JOptionPane.showMessageDialog(null, e);

>}

> d an email and it doesnt throw any exceptions

Have you tried:

try{

SmtpGmail E = new SmtpGmail (message);

E.email();

System.out.println("Sucess");

}catch (Throwable e){

e.printStackTrace();

}

zadoka at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 18
i'll try it hold on pleaseand sorry for being late last time , because i had to keep on trying to see why its acting fool that it doesnt even throw anythingone second sorry again
--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 19

> i'll try it hold on please

>

> and sorry for being late last time , because i had to

> keep on trying to see why its acting fool that it

> doesnt even throw anything

>

> one second sorry again

Don't worry, I am not just sitting here waiting for a response. When I look back at the forums it shows me when there are new posts. The next time I look might be 3 minutes from now, or 3 days.

zadoka at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 20

i have a question before i test it

the code has been modified but where would it print that ?

because remeber i am using windows and its like a jframe and stuff , is it gonna print it on the screen or should i use option panes?

because when i use optionpane to make the message appear it complains

so how should i make the message appear?

thanks

--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 21

i have tried it exactly the way u asked me too , and it never prints anything , its driving me crazy

and what makes me go more crazy is that the program neevr crashes i can continue doing my work but it just never send emails

if i use eclips, the whole program including sending emails works perfectly thats soo wierd

maybe this time it doesnt print anything because it doesnt show the message on the screen , how can i make it pop up on the screen?

thanks

--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 22

> maybe this time it doesnt print anything because it

> doesnt show the message on the screen , how can i

> make it pop up on the screen?

yes, println commands aren't going to popup in a gui.

Run the jar at the command line like you did before so that you have a console for the message to appear on. Or wrap them in a JOptionPane if you prefer.

zadoka at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 23

> yes, println commands aren't going to popup in a

> gui.

>

> Run the jar at the command line like you did before

> so that you have a console for the message to appear

> on. Or wrap them in a JOptionPane if you prefer.

i used cmd

it prints nothing

i prefere wrapping it , but i dont know how cause optionpane complains about having an object and not a String in it

do u have an idea of how to print the stack on a pop up message?

thanks

--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 24
Does it even print "Success"? If yes then the there is no error, if no then it is not even getting to the try block and the problem is happening before it.About the stack trace: You could call getStackTrace() or at least getMessage().
zadoka at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 25
no thats the thing IT DOES NOT print sucessI'll get message one second
--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 26
Well put a println right before the try{ If it doesn't print then there is something happening even before the the try block.
zadoka at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 27

OMG FINAAAAAAAALLLLLLLLLLLLLLLLLLLYYYYYYYYYYYYY

it printed something lol

here u go this is the message that i get after i wrapped it with JOptionPane

"com/jscape/inet/email/EmailMessage"

now lets focus on this

in my email class i am importing this

com.jscape.inet.email.*;

so it is exactly what i expected , it doesnt see the library i guess

--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 28
so i guess we need to fix the problem of how to make sure that the jar file includes the library
--CoolK--a at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 29
> so i guess we need to fix the problem of how to make> sure that the jar file includes the libraryWell, you checked that. I would suggest that you find where the program actually stops. It is somewhere before the try catch.
zadoka at 2007-7-9 21:26:22 > top of Java-index,Desktop,Developing for the Desktop...
# 30

i know i checked it but

everythign before the try catch , works and everything gets excuted

and remeber when we tries the println before ? it did print everything

its only when it tries to initialize an object of the email class and the reason behind this is that it doesnt see the library

i just wanna point out that my library is a jar file too

so i dont know how would i make sure that it includes the library

i thinki am a bit confused about the classpath and the menifest

if u dont mind telling me how to make sure that my library is included in the jar file

thanks

--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 31
> i thinki am a bit confused about the classpath and> the menifest Check this out: http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
zadoka at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 32

this is my manifest:

__

Manifest-Version: 1.0

Sealed: true

Main-Class: MyhomeBank

__

this is my classbath

_

<?xml version="1.0" encoding="UTF-8"?>

<classpath>

<classpathentry kind="src" path="">

<attributes>

<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="F:/eclipse/workspace/banking/emailf/lib"/>

</attributes>

</classpathentry>

<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

<classpathentry kind="lib" path="F:/eclipse/workspace/banking/emailf/lib/email.jar"/>

<classpathentry kind="output" path=""/>

</classpath>

_

do you see any problems?

isnt the email library included?

i think the bath is there and everythign is there

Message was edited by:

--CoolK--

--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 33
The email lib should be in your manifest and it is not.
zadoka at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 34
how od i add it?
--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 35
See the link in reply 31.
zadoka at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 36

i did see the link 5 times and i read it but i am confused because i use windows and not the command line

like i tried to do it this way which is

creating a file called Manifest.txt

i put class phath and i put my libraryin there

then i went to file and export jar

and i selected to include the manifest that ihave created

result: it just added that txt file to my jar nothign else and all the errors are still there

do u have an idea of how to do this using windows?

thanks i preciate all ur help man

--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 37

> i did see the link 5 times and i read it but i am

> confused because i use windows and not the command

> line

You can open a console and do it.

>

> do u have an idea of how to do this using windows?

>

I guess you mean without the command line. Well, normally I build jars with an Ant build file, but there is small learning curve on Ant (but I think it is worth it).

Anyway, are you sure it is a path problem? Did you ever find an Exception. If could be something to do with access to the email or something else?

Where you able to narrow it down to an exact line of code that it stops at?

zadoka at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 38

yes i am sure man , because it doesnt make sense to have problem in the email in a jar file but inside eclips , it doesnt have any problems and it wouls send emails

again the exception is this

com/jscape/inet/email/EmailMessage

and what ihave in my email class is this

import com.jscape.inet.email*.

now the reason is says that error is this

EmailMessage message = new EmailMessage();

the previous line is in my email class , so obviously its gonna look for this path

com/jscape/inet/email/EmailMessage

but it doesnt exist , because it doesnt see the library that ihave included

let me know what u think about that and till me if i make sense or not

--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 39
Like I said make sure that the manifest is correct. Also, check to make sure that the jars are where the manifest expects them.For example if your jar is in a folder and your manifest has:lib/someother.jarMake sure that someother.jar is in the lib folder.
zadoka at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 40
its all good , thank u very much man , i think i need to move on from windows to linux just to use the command line and test it to see if it would combine them like the website u gave me earlier because i am really confused about this problem , it neveer happeend to me before
--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 41

> its all good , thank u very much man , i think i need

> to move on from windows to linux just to use the

> command line and test it to see if it would combine

> them like the website u gave me earlier

You can jar a file on the windows command line just as well as linux.

> because i am really confused about this problem , it

> neveer happeend to me before

Like I said make sure that the jar files you depend on, are in the location that the manifest expects.

zadoka at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...
# 42

i gave up , been 2 days trying to do this , and there is no way to load this library , or knowing if its really the library or something else

i wish that there is some body who can tell me a step by step way of how to create a jar file application on windows using eclips and making sure that my (jar library) is included in it , so if it doesnt work , id know that its something else but not the library

thanks

--CoolK--a at 2007-7-9 21:26:25 > top of Java-index,Desktop,Developing for the Desktop...