• Post Reply Bookmark Topic Watch Topic
  • New Topic

jar file only launches first image in GUI

 
David VanBom
Greenhorn
Posts: 5
Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! My first post in java ranch...

I packaged my application as a jar, which i hoped would be runnable. It is, but only the first image loads! Before packaging there is no problem...
Any ideas?
I package the program as so: jar cvfm Thingy.jar Manifest.txt *.class Pictures/

Manifest.txt is:
Main-Class:Intro

(Intro.class is the starting point of the program).
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My idea is we don't have nearly enough information.

We don't know where your images are. We don't know how you're loading them. We don't know how many are supposed to "load", or indeed why you say that only "the first one" is loading.

You could put make a jar with two pictures and a GUI to load them, using whatever loading code you are using now. That would be quite small enough to post the entire code, and then we could probably help you. Unless, of course, you discover the problem yourself while making the example.
 
David VanBom
Greenhorn
Posts: 5
Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the fast answer. Those suggestions helped me find the problem, I peeled away everything except for the first few images and think I found the problem: I can't connect to my MySql databases from inside the jar-file (I was trying to fill up a JCombobox from local mysql database on my computer)!

I'm looking around for solutions, but it seems that you can't package a MySql database inside a jar-file? Apart from running on my computer locally, which works (without jar) , I want the application to run through java webstart, and I'm thinking it's maybe better to have the databases externally and connect to them through the internet. Ideas? Suggestions?

This is the class that doesn't work ( before packaging as a jar it works fine):


 
Ralph Cook
Ranch Hand
Posts: 479
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no experience with treating an entire database as read-only, and of course you cannot write to it within the jar file (at least, trying to do so doesn't make a lot of sense to me). So it is quite possible that even simple RDBMS depend on having write access to their files, or that they only operate on actual files, not streams of bytes from jar files.

I am currently working on a program that will start from Java WebStart, but its database will be files created on the machine when the program is installed, and left there. It will need to be signed, and the user/installer will have to authorize operating out of the sandbox for the application.

If all you're doing is filling up a combo box, then perhaps you don't really need a full-on SQL database -- just files with the values to put in the combo.
 
David VanBom
Greenhorn
Posts: 5
Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved it! The manifest file needed the mysql-connector-jar file added to the classpath, and the application also needed to be in the same directory as the mysql-connector -jar file.

With a manifest file that reads:

Main-Class: IntroScaledDown
Class-Path: mysql-connector-java.jar

i can create a runnable jar that connects to my local database with the above code via
jar cfmv Test.jar Manifest.txt *.class Pictures/

Yey!

Thanks for help and time, I do need the database, the whole application is based on it... Now to see if this wants to work with java webstart
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!