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 I found that inner classes cause problem run my jar file (no problem making the jar or compiling), Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "I found that inner classes cause problem run my jar file (no problem making the jar or compiling)," Watch "I found that inner classes cause problem run my jar file (no problem making the jar or compiling)," New topic
Author

I found that inner classes cause problem run my jar file (no problem making the jar or compiling),

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
I found that inner classes cause problem run my jar file (no problem making the jar or compiling), well in this case of inner classes what must be done?

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
jar cmf SMTPClient.mf SMTPClient.jar SMTPClient.class SMTPClient.java success
java -jar SMTPClient.jar
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

When you create your JAR file you're only adding SMTPClient.class and SMTP.java. Inner classes are compiled to their own class files, in this case SMTPClient$SendAction.class. You'll need to include that in the JAR file.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
how include inner classes below:
SMTPClient$SendAction.class
or
SendAction.class
??
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
either is correct?
I triedbut is it needed alsi include javax/mail/Message class, where found?>>>>


Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
subject:javax.mail.Message
I used
jar cmf SMTPClient.mf SMTPClient.jar SMTPClient.class SMTPClient$SendAction.class SMTPClient$UpdateListener.class mail.jar SMTPClient.java

but gives (how include another jar in my jar?)
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10532
    
    9

http://one-jar.sourceforge.net/


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
Maneesh Godbole wrote:http://one-jar.sourceforge.net/


I get some hint although confused,
after I put from RAR zip utility a folder(/lib) and mail.jar in, I get below...is any special command in manifest or to run? Is mail.jar the only I need or?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Put a Class-Path entry in your manifest file which points to the location of mail.jar relative to your own JAR file. For example, "Class-Path: mail.jar" or "Class-Path: lib/mail.jar".
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
I get again error...???
how add a jar in a folder, of another jar from CLI LIKE
jar cmf SMTPClient.mf SMTPClient.jar SMTPClient.class SMTPClient$SendAction.class SMTPClient$UpdateListener.class mail.jar SMTPClient.java
?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

You don't put mail.jar inside the JAR file. You put it in a lib folder that exists in the same folder as your JAR folder. Very few solutions allow you to add dependency JAR file inside the JAR file itself and work immediately. One JAR, as Maneesh suggested, is one of those but I've never used it.
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
hence this is a simple GUI EMAIL SEND FORM APP JAVA SE, When on RUN from CLI I email delivered but not delivered when RUN by clicking shortcut...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Do you have the following in the folder where the JAR is located?
Because with a Class-Path entry of lib/mail.jar that's what it should look like.
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
this is correct?

Manifest-Version: 1.0
Created-By: 1.6.0_15 (Sun Microsystems Inc.)
Class-Path: lib/mail.jar
Main-Class: SMTPClient

app run only CLI, No:jar run / shortcut run

no errors only email not delivered... folder structure correct

matters many jars in containing folder, or folder url with spaces?
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
first time running jars[gui] non-success, needed anything else from mail.jar any other lib?

in shortcut
target:"C:\Users\User\Documents\TextBooksDataFiles\Java Network Programming, 3rd Edition\jnp3examples\examples\19\SMTPClient.jar"
startin:"C:\Users\User\Documents\TextBooksDataFiles\Java Network Programming, 3rd Edition\jnp3examples\examples\19"
the jar is in the
C:\Users\User\Documents\TextBooksDataFiles\Java Network Programming, 3rd Edition\jnp3examples\examples\19\lib\mail.jar

only from running [CLI] the- java SMTPClient .class -email delivered

this is correct ... how many lines must follow: SMTPClient?

Manifest-Version: 1.0
Class-Path: lib/mail.jar
Created-By: 1.6.0_15 (Sun Microsystems Inc.)
Main-Class: SMTPClient

in this case mail.jar needed ONLY outside the SMTPClient.jar?
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
I run
java -jar SMTPClient.jar // CLI
->simple send email, but when press send button appeared:
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Have you included all .class files generated by the compiler, in the right folder structure that must match the package structure?
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
I added SMTPClient$SendAction$1 and now works, thks!

in the above class name "$" show inner classes? may included in any order in->...?

jar cmf SMTPClient.mf SMTPClient.jar SMTPClient.class SMTPClient$SendAction.class SMTPClient$SendAction$1.class SMTPClient$UpdateListener.class SMTPClient$1.class SMTPClient$2.class SMTPClient$3.class SMTPClient$4.class SMTPClient.java
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

$1 etc are anonymous inner classes. As you already have seen, named inner classes have their name added, like SMTPClient$SendAction.class. The order is most likely the order of occurrence in the source file but I don't know if the Java Language Specification has a hard rule for this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I found that inner classes cause problem run my jar file (no problem making the jar or compiling),