Java Jar File Problem

Java Jar File Problem

Page 1 of 1

10 Replies - 2012 Views - Last Post: 03 March 2007 - 07:20 AM Rate Topic: -----

#1 codeninja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 16-February 07

Java Jar File Problem

Posted 26 February 2007 - 12:22 AM

Hi. I have a working project which I made in BlueJ. And it works fine from Bluej thanks to all the info I got from this site.

But when I export the JAR file it is not working. And I even loaded everything into Eclipse. It works in Eclipse but the Eclipse exported jar also fails.

I did select the main class via the export settings.

I am attaching the file. If the code is useful please take it. And if you can figure out why it will not run give me a message.

I added two versions of the Jar i tried to make. new4.jar is missing a class I didnt use but left in the original jar.

Codeninja

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Java Jar File Problem

#2 GWatt  Icon User is offline

  • member icon

Reputation: 270
  • View blog
  • Posts: 3,068
  • Joined: 01-December 05

Re: Java Jar File Problem

Posted 26 February 2007 - 05:06 AM

Um... I couldn't open the file

This post has been edited by GWatt: 26 February 2007 - 05:06 AM

Was This Post Helpful? 0
  • +
  • -

#3 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: Java Jar File Problem

Posted 26 February 2007 - 05:52 AM

View PostGWatt, on 26 Feb, 2007 - 12:06 PM, said:

Um... I couldn't open the file

I got a message saying the file was corrupt!
Was This Post Helpful? 0
  • +
  • -

#4 GWatt  Icon User is offline

  • member icon

Reputation: 270
  • View blog
  • Posts: 3,068
  • Joined: 01-December 05

Re: Java Jar File Problem

Posted 26 February 2007 - 05:57 AM

This is the message I got.
Posted Image

However, I KNOW I can open archive files because I do it all the time. Unless he zipped it using rar and then renamed, I should be able to open it.

This post has been edited by GWatt: 26 February 2007 - 06:01 AM

Was This Post Helpful? 0
  • +
  • -

#5 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Java Jar File Problem

Posted 27 February 2007 - 12:17 AM

Upload your Archive again.
Was This Post Helpful? 0
  • +
  • -

#6 codeninja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 16-February 07

Re: Java Jar File Problem

Posted 01 March 2007 - 11:06 PM

View Postborn2c0de, on 27 Feb, 2007 - 12:17 AM, said:

Upload your Archive again.

Here it is in ZIP format. It is nothing more than a HelloWorld script. I am just trying to figure out why when I try and click and run it---- nothing happens.

And I set my classpath and if I run an un-jar script from the command line it seems fine.

Codeninja

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#7 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Java Jar File Problem

Posted 01 March 2007 - 11:59 PM

What's Wrong?
It works fine for me.

Did you use this command at the command line to run your app?
java -jar hello_nosource.jar

Was This Post Helpful? 0
  • +
  • -

#8 codeninja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 16-February 07

Re: Java Jar File Problem

Posted 02 March 2007 - 01:41 AM

View Postborn2c0de, on 1 Mar, 2007 - 11:59 PM, said:

What's Wrong?
It works fine for me.

Did you use this command at the command line to run your app?
java -jar hello_nosource.jar


If i wrapp it in an exe file it works as well. But from my desktop or command line it just does nothing. Maybe my java environment variables are bad
Was This Post Helpful? 0
  • +
  • -

#9 Programmist  Icon User is offline

  • CTO
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,833
  • Joined: 02-January 06

Re: Java Jar File Problem

Posted 02 March 2007 - 07:08 AM

If I run it from a command line it works, but double-clicking does nothing. It's been a while since I've written a console app, so I'm not sure if that's normal.
Was This Post Helpful? 0
  • +
  • -

#10 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Java Jar File Problem

Posted 03 March 2007 - 12:07 AM

Well yes, double clicking won't do anything because there won't be a console to write the text to.

The System.out.println() outputs data to a Console, but it doesn't create one if a Console doesn't exist.

Such programs have to be used using the Commandline.

Use the showMessageDialog() from the JOptionPane Package to display the text.

Programmers generally write a GUI for JAR files, so that when you double click it, a window appears which waits for user input.
Was This Post Helpful? 0
  • +
  • -

#11 Programmist  Icon User is offline

  • CTO
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,833
  • Joined: 02-January 06

Re: Java Jar File Problem

Posted 03 March 2007 - 07:20 AM

Right. Now I remember. Ahh, the good 'ol days of console apps. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1