Results 1 to 9 of 9
Thread: netbeans-make jars-prb
- 09-20-2010, 11:51 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 21
- Rep Power
- 0
[SOLVED]netbeans-make jars-prb
Hey everyone, i have this prb, hope there is anyone that could help me :
My application is actually a client that sends queries to a server. I want to run 2 or more clients concurrently and send queries to the server .
When i build the code from netbeans and press the run button for one client every button works good. I tried to run it using the command from cmd
java -jar file_name.jar
and when i pressed the first button i got this message
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:443)
at java.lang.Integer.parseInt(Integer.java:514)
at graphicpresence.SipDynamicTree.register(SipDynamic Tree.java:214)
at graphicpresence.SipDemo.actionPerformed(SipDemo.ja va:115)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:253)
at java.awt.Component.processMouseEvent(Component.jav a:6101)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3276)
at java.awt.Component.processEvent(Component.java:586 6)
at java.awt.Container.processEvent(Container.java:210 5)
at java.awt.Component.dispatchEventImpl(Component.jav a:4462)
at java.awt.Container.dispatchEventImpl(Container.jav a:2163)
at java.awt.Component.dispatchEvent(Component.java:42 88)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4461)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4125)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4055)
at java.awt.Container.dispatchEventImpl(Container.jav a:2149)
at java.awt.Window.dispatchEventImpl(Window.java:2478 )
at java.awt.Component.dispatchEvent(Component.java:42 88)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 604)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:138)
My questions are:
a) How to make jars (i know that i have to configure somehow the manifest.txt but i dont know how?)
b)I want to run each jar not from the dist directory of the netbeans, how to do this?
thanx in advance!Last edited by jlmp; 09-30-2010 at 04:19 AM.
- 09-21-2010, 12:06 AM #2
Member
- Join Date
- Mar 2010
- Location
- Hilton Head, SC
- Posts
- 34
- Rep Power
- 0
The message is a stack trace and you said you pressed a button so this is what I'm thinking is happening:
You have a JTextField and a button. When you press the button it takes the contents of the field and tries to parse it as an integer as so:
The error is saying you are trying to parse null so I'm guessing you are just pressing the button without entering any data and that is triggering the printing of the stack trace. If you do not want the output, just remove the e.printStackTrace(); from your code.Java Code:try { int some_int = Integer.parseInt(textField.getText()); } catch (Exception e) { e.printStackTrace(); }
Note: Your 'e' may be a different name than 'e'
The easiest way to make a .JAR in my book is via command line:
First, make a file called Manifest.mf (It can technically be any name) with the contents:
Obviously replace YourMainClassName with your actual class that contains your main().Java Code:Class-Version: 1.0 Main-Class: YourMainClassName Class-Path: .
Place this file in with your class files, then traverse to that location via command line and issue the command: jar -cvfm jarname.jar Manifest.mf *.class
This will create a JAR name jarname.jar, it will include the Manifest.mf for the manifest file, and it will place all class files from that directory inside. Once that jar has been compiled you can simple double click it as if it were an executable to run it.
To run the JAR in a directory other than the Netbeans directory, simple move the JAR to the desired location.
- 09-21-2010, 01:13 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 21
- Rep Power
- 0
Shall i ask another question, cause i am bit newbie with this issue! First of all, the thing with the try catch okz it cant find a txt lets say its not a prb, i can put the txt for each jar.
Secondly, my class that has the main() is call SipDemo... i tried to do what u told me. i put all the *.class (i copied from the netbeans), i made the jarname.jar and it says something like
Exception in thread "main" java.lang.NoClassDefFoundError: SipDemo (wrong name: graphicpresence/SipDemo)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :637)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:277)
at java.net.URLClassLoader.access$000(URLClassLoader. java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 68)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:336)
I have to admit another issue that bothers me...well except from the fact that i need to make a jar with my code, i have 2 jars which i need them for library... how do i include it them? I dont know if i am making so much ridiculous questions but i ve read quiet a few forums and i got lost...
thanx in advance, again!!!Last edited by jlmp; 09-21-2010 at 01:16 AM.
- 09-21-2010, 01:53 AM #4
Is the class SipDemo in a package? If it is you must add the package name to the classname on the Main-Class: field in the manifest file.NoClassDefFoundError: SipDemo (wrong name: graphicpresence/SipDemo)
- 09-21-2010, 04:43 AM #5
Member
- Join Date
- Jan 2010
- Posts
- 1
- Rep Power
- 0
you are right about that, i also have it in a package ;)i ll try to see what can i do with this, i have found another link for jars (found it seeking the forum acutally) i ll read it and see how to make it work, thanx for the answers, hope to solve it soon - i hope today-, otherwise, i ll ask you again!
- 09-21-2010, 09:10 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
I think Netbeans automatically jars up your code.
(Though learning how to do it by hand is a Good Thing).
Look in the project directory and see if there is a dist directory...
- 09-21-2010, 11:02 AM #7
Member
- Join Date
- Sep 2010
- Posts
- 21
- Rep Power
- 0
Goodmorning!!!
yeah the prb is that i need more than 2 clients with different usernames and passwords (which are taken from a file during the running)to run simultaneously, so i suppose that i must try it by hand cause netbeans do it everything itself. And when i press the build button only one jar can be generated in the dist file. With this scenario -the fact that i want more than one client to run concurrently- does anyone know if netbeans has any feature to do that or i have to do it by hand?!?!
- 09-21-2010, 11:21 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Why not just change the values in the file that gets included in the jar?
To be honest you could probably get Netbeans to build several jars at one go (using some numeric suffix), supplying a list of usernames and passwords which it would add to the username-file. That would be an ant thing, though.
- 09-30-2010, 04:08 AM #9
Member
- Join Date
- Sep 2010
- Posts
- 21
- Rep Power
- 0
My problem was solved, it was much easier than i thought so ,
all i had to do was to make was my differnet folders and copy and pasty in there :
a) the jar
b)the folder lib
c)the manifest file
d)the file that I use in order to get the username and passwords
I also changed my code in order to read the file from "user.dir" and that was all...
Thanks for your comments!!!
ps: I cant find where the button that says SOLVED is located :( :( :(Last edited by jlmp; 09-30-2010 at 04:10 AM.
Similar Threads
-
Communication between two Jars
By Gijava in forum Advanced JavaReplies: 1Last Post: 06-26-2009, 04:59 PM -
how to make installation files using netbeans 6.5
By santhosh_el in forum AWT / SwingReplies: 1Last Post: 03-25-2009, 11:26 AM -
More efficient in memory? Multiple Jars or Single Jars with lot's of Classes
By dark_cybernetics in forum New To JavaReplies: 0Last Post: 08-19-2008, 04:44 PM -
Preblem with JARs
By bizmut in forum EclipseReplies: 1Last Post: 06-04-2008, 05:41 PM -
how to find unused jars??
By orchid in forum EclipseReplies: 4Last Post: 06-08-2007, 10:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks