Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Jar file only works on my pc

Reply
Thread Tools

Jar file only works on my pc

 
 
stinkinrich88@googlemail.com
Guest
Posts: n/a
 
      02-03-2007
Hello! I've created a jar file, works fine on my pc (in any directory)
but won't work on anyone elses computer. (One person got the "can't
find main class" message")

any ideas? this is the first time I've ever created a jar file

thanks!

 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      02-03-2007
On Feb 3, 8:33 am, (E-Mail Removed) wrote:
> Hello! I've created a jar file, works fine on my pc (in any directory)
> but won't work on anyone elses computer. (One person got the "can't
> find main class" message")
>
> any ideas? this is the first time I've ever created a jar file
>
> thanks!



Need a lot more info.
Does the jar contain more than one class?
How are you creating the jar?
A jar file contains a manifest file and a pile of classes. Have you
looked at the jar to see what is inside? Do you call any classes in
libraries (report generators, etc.)?

 
Reply With Quote
 
 
 
 
iherage
Guest
Posts: n/a
 
      02-03-2007
On 2月3日, 下午2时33分, (E-Mail Removed) wrote:
> Hello! I've created a jar file, works fine on my pc (in any directory)
> but won't work on anyone elses computer. (One person got the "can't
> find main class" message")
>
> any ideas? this is the first time I've ever created a jar file
>
> thanks!


My suggestion is to delete all the jar file and redo the process.

 
Reply With Quote
 
Alex Hunsley
Guest
Posts: n/a
 
      02-03-2007
iherage wrote:
> On 2月3日, 下午2时33分, (E-Mail Removed) wrote:
>> Hello! I've created a jar file, works fine on my pc (in any directory)
>> but won't work on anyone elses computer. (One person got the "can't
>> find main class" message")
>>
>> any ideas? this is the first time I've ever created a jar file
>>
>> thanks!

>
> My suggestion is to delete all the jar file and redo the process.


If they do that, and recreate the jar in exactly the same way, they're
most likely just going to be back at square one with the same problem.

Have google for Jars and manifest files. One decent page is
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html - read up on
Manifest and the Main-class property.
lex

 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      02-03-2007
On 3 Feb, 13:33, (E-Mail Removed) wrote:
> Hello! I've created a jar file, works fine on my pc (in any directory)
> but won't work on anyone elses computer.


As a wild guess, it's not the JAR that's at fault. Instead it probably
has a dependency on something that your PC has installed on the
classpath, but their's doesn't.

 
Reply With Quote
 
stinkinrich88@googlemail.com
Guest
Posts: n/a
 
      02-03-2007
On 3 Feb, 16:05, "Andy Dingley" <(E-Mail Removed)> wrote:
> On 3 Feb, 13:33, (E-Mail Removed) wrote:
>
> > Hello! I've created a jar file, works fine on my pc (in any directory)
> > but won't work on anyone elses computer.

>
> As a wild guess, it's not the JAR that's at fault. Instead it probably
> has a dependency on something that your PC has installed on the
> classpath, but their's doesn't.


ahh your joking!! I just posted a massive post and it didn't show up.
I clicked "reply to author" and I think it went to Andy. Would you
mind posting it for me please?? sorry! (thanks!)

 
Reply With Quote
 
Thorsten Kiefer
Guest
Posts: n/a
 
      02-03-2007
Do you use JBuilder or Netbeans ?


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Hello! I've created a jar file, works fine on my pc (in any directory)
> but won't work on anyone elses computer. (One person got the "can't
> find main class" message")
>
> any ideas? this is the first time I've ever created a jar file
>
> thanks!


 
Reply With Quote
 
stinkinrich88@googlemail.com
Guest
Posts: n/a
 
      02-04-2007
ok, quick note until andy posts my post:

I use textPad 4 to compile (so just javac) and command line to make
jar. I open the jar file using 7zip and all of the class files are
there (as in, the ShutTheBox.class and ShutTheBox$1-10.class (what are
these for!!)) plus the gif files, plus a folder called META-INF with
the manifest file in it. It works fine in any directory on my pc.

Do you recon it's the class file? My mate can't get the applet version
on http://www.txfiles.co.uk/rich/ShutTheBox.html to work. can you? All
my other applets work fine. Is it the stupid $ signs?

I think I have the $'s because of my actionListener inner classes. Is
this a problem? good practice etc?

thanks!!!

 
Reply With Quote
 
iherage
Guest
Posts: n/a
 
      02-04-2007
On 2月4日, 上午1时02分, (E-Mail Removed) wrote:
> ok, quick note until andy posts my post:
>
> I use textPad 4 to compile (so just javac) and command line to make
> jar. I open the jar file using 7zip and all of the class files are
> there (as in, the ShutTheBox.class and ShutTheBox$1-10.class (what are
> these for!!)) plus the gif files, plus a folder called META-INF with
> the manifest file in it. It works fine in any directory on my pc.
>
> Do you recon it's the class file? My mate can't get the applet version
> onhttp://www.txfiles.co.uk/rich/ShutTheBox.htmlto work. can you? All
> my other applets work fine. Is it the stupid $ signs?
>
> I think I have the $'s because of my actionListener inner classes. Is
> this a problem? good practice etc?
>
> thanks!!!


I think the $ is needed because when you write more than one classes
in a file, java compiler will produce exact the same number of class
files.
I have encountered this kind of problems before. As I remembered I
just carried out the procedure again and carefully followed the
instruction provided by sun.

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      02-04-2007
On Feb 4, 11:02 am, (E-Mail Removed) wrote:
....
> I use textPad 4 to compile (so just javac) and command line to make
> jar. I open the jar file using 7zip and all of the class files are
> there (as in, the ShutTheBox.class and ShutTheBox$1-10.class (what are
> these for!!))


Inner/anonymous classes.

>..plus the gif files, plus a folder called META-INF with
> the manifest file in it. It works fine in any directory on my pc.


The best way to prepare a jar is using the jar tool
provideed with the SDK. Some other tools will use
a less rigourous file structure, and offer non-standard
forms of compression.

> Do you recon it's the class file? My mate can't get the applet version
> onhttp://www.txfiles.co.uk/rich/ShutTheBox.htmlto work. can you?


Yes it works fine for me, using Java 1.6.
(or at least seems to - 'spinnable dice' appear etc.)
Did your 'mate' get some console output?
What was it?

Was this not originally a question about how to get
an *application* working?

>..All
> my other applets work fine. Is it the stupid $ signs?
>
> I think I have the $'s because of my actionListener inner classes. Is
> this a problem?


No - so long as they are all included.

>...good practice etc?


'Neither good nor bad' - it depends on the overall
design whether it makes sense to have them.
I do *not* believe this is the cause of the problem,
unless you have not included them all.

One last thing..
'One person got the "can't find main class" message"'
...If at all possible, get a copy/paste of that message.

Andrew T.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM
how to disassembly a .jar file? how to see what are the classes inside the .jar file? lucy Java 6 09-07-2004 09:54 PM



Advertisments