NetBeans 5.5 + jar library -> can't compile prj

I use NetBeans 5.5

I have jar file MySQLconnector.

I've included it as Library.

i have icons for buttons in GUI. I've included icons folder to project.

I've used GUI builder to develop my application.

When I run my application in NetBeans 5.5. I do not have any problems.

1. Icons are loaded into my Buttons

2. I can interact with DataBase with help of connector.

Everything works.

Question:

How can I include my icons and MySQLconnector (jar file) into my FINAL jar file?

I found a topic: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=752094

1.But I do not see any lib folder n my final JAR file.

2.Final Jar file doen't have my library+icon

3. I can't run my final JAR because JRE says: Couldn't find main class.

[860 byte] By [Holoda] at [2007-11-26 22:41:41]
# 1

You need to read a couple tutorials on JAR files to get a better understanding of what they are and what is capable with JAR files.

First of all, your MySQL JDBC JAR file will not be found if you package it WITHIN your application JAR file. Jar files should never be packaged within other JAR files.

Your application will need to be seperate from the MySQL connector JAR file, and when running Java you will need to point the MySQL jar file to your classpath argument so that it can be found.

Another misconception you have is that by simply placing the MySQL jar file within a folder called, 'lib' that everything will simply, "work". While that is good practice it is simply not the case.

Secondly, your JAR file is supposed to contain a file called MANIFEST.MF which is a simple text file that specifies properties of the JAR file. You need to add the following line to your JAR file for it to be able to find your Main class.

Main-Class: com.db.package.WhateverObject

As for not being able to find icons, I am simply not getting what you are saying.

maple_shafta at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 2

1.I've read already about Jar.

I know now that jar file can't exist in other Jar file

Here is my MANIFEST file:

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.6.5

Created-By: 1.6.0-b105 (Sun Microsystems Inc.)

Main-Class: GUI.MainForm

Class-Path: lib/resource lib/swing-layout-1.0.1.jar

lib/mysql-connector-java-5.0.4-bin.jar

lib/AbsoluteLayout.jar

lib/mysqlconnectorjava504

So as you can see It need Jar with connector + Jar with swing (I use FreeLayout)

I have to put them into my lib folder

1.Where is this folder lib?

2.I have to supply my Jar file bat file (to modify system PATH variable)?

3. Where can I find solutions for such problem?

I am sure a lot of applications consist of several Jar files.

4.I talk about icons for buttons. I have a GUI. There are some buttons with my icons.

Where do I have to place them?

Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 3

1. The lib folder is relative to your application JAR, or at least it should be. If it can't find a lib folder in the same directory as your JAR file then your third-party jar files will not be found by the application and you will get a NoClassDefFoundError.

4. The image files that supply your button icons must ALWAYS be placed in your JAR relative to the class that is using them. If not then your application will not be able to find them.

3. I am not sure what you mean about a BAT file and updating the PATH environment variable. I assume you mean the CLASSPATH environment variable. If you specify the external JARs in your MANIFEST.MF file then why do you need to do this in a BAT file?

maple_shafta at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 4

Ok. I can't get It.

My manifest file code:

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.6.5

Created-By: 1.6.0-b105 (Sun Microsystems Inc.)

Main-Class: GUI.MainForm

Class-Path: lib/resource lib/swing-layout-1.0.1.jar lib/mysql-connecto

r-java-5.0.4-bin.jar

X-COMMENT: Main-Class will be added automatically by build

So I have folder dist There is:

dfree.jar//my application jar file

folder lib///folder with jars

lib/mysql-connector-java-5.0.4-bin.jar

lib/swing-layout-1.0.1.jar

I try to launch my dfree.jar

Nothing happens!

No error messages, no application. Nothing.

What does it mean?

I've created folder lib near my compiled project jar.

What else I have to do?

I do not understand it... Can you help me?

Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 5

Oh...Stupid thing!!!!

YES!!!! The problem is elsewhere.

I've created folder lib with all necessary additional jar's and it works

I can launch frame.

But I can't launch form created with help of NetBeans 5.5. GUIBuilder.

So I have to dig why I doesn't launch.

Sorry for making troubles.

Your solution is right.

Problem is in my main class which uses form..........((((

Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 6

Hello,

I have a similar error :

Exception in thread "AWT-EventQueue-10" java.security.AccessControlException: access denied (java.net.SocketPermission whatalotto resolve)

at java.security.AccessControlContext.checkPermission(Unknown Source)

This happens on the client side. The Applet comes up but when a submit of data is done to the server, I see the error.

I used Netbean 5.5 to create the classes but there is no way to add any info to the manifest.mf via the IDE. I can do this manually of course and that also does not work.

Can you help? Thanks

rremedioa at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 7
This error occurs when you launch your applet in IDE or when you try to lauch your jar file?
Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 8
I launch the applet via a browser not on the server machine. The html file has the applet tag which has the codebase reference. The code base reference has the path to the class folder.<APPLET codebase="classes" code="org/client/Client.class" width=480
rremedioa at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 9

Link to russian forum:

http://forum.ixbt.com/topic.cgi?id=40:3047

See error report. Is it close to yours?

java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.jtwain)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkLink(Unknown Source)

at java.lang.Runtime.loadLibrary0(Unknown Source)

at java.lang.System.loadLibrary(Unknown Source)

at jtwain.JTwain.init(JTwain.java:191)

at JTwainMng.<init>(JTwainMng.java:31)

at GUI_ChooseType.init(GUI_ChooseType.java:105)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

So, I will give you explanation in few words:

The thread author

Mystic_hardware successfully runs applet in command line, but can't lauch it through web-page.

This applet uses dll, which is on the server-side.

The other guy suggest to Read Manual and gives an idea, that author has to SUBSCRIBE applet.

Also, see this explanation: (in english)

http://java.sun.com/j2se/1.4.2/docs/guide/deployment/deployment-guide/upgrade-guide/article-04.html

I hope, the last one link will help you.

As I know, applet can't establish connection to other servers. It can interact only with server where applet is placed.

Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 10
Thanks.I did sign the jar file but applet tag does not reference the jar file but the *.class file.As to applets not establishing a connection to a server, is there any documentation on this?Thanks
rremedioa at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 11
Hm...I've never worked with applets.I can't provide you with uncertain information.Sorry =)
Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 12
That's is OK.Check this site for more info on applet cient / server interaction. http://www.ecst.csuchico.edu/~tfsmiles/java/server/
rremedioa at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...
# 13
Thank you!
Holoda at 2007-7-10 11:56:42 > top of Java-index,Desktop,Deploying...