please tell me step of converting java source code into jar in netbean or if any software available please send me download link of it.

Use the javac command to create the .class files
Use the jar command to create the jar file.

Hi Norm.
Watch out for this OP - already in trouble with Peter Budo for not showing any effort, and is starting to troll other people's posts. J

Please tell me syntax or some example of jar command.

you were just given what you need to know. tried running these commands yet?

I already run jar command it showing me following

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd\

C:\>cd bank1

C:\bank1>jar bank
Illegal option: b
Usage: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] fil
es ...
Options:
    -c  create new archive
    -t  list table of contents for archive
    -x  extract named (or all) files from archive
    -u  update existing archive
    -v  generate verbose output on standard output
    -f  specify archive file name
    -m  include manifest information from specified manifest file
    -e  specify application entry point for stand-alone application
        bundled into an executable jar file
    -0  store only; use no ZIP compression
    -M  do not create a manifest file for the entries
    -i  generate index information for the specified jar files
    -C  change to the specified directory and include the following file
If any file is a directory then it is processed recursively.
The manifest file name, the archive file name and the entry point name are
specified in the same order as the 'm', 'f' and 'e' flags.

Example 1: to archive two class files into an archive called classes.jar:
       jar cvf classes.jar Foo.class Bar.class
Example 2: use an existing manifest file 'mymanifest' and archive all the
           files in the foo/ directory into 'classes.jar':
       jar cvfm classes.jar mymanifest -C foo/ .


C:\bank1>

you know ... Google the Wise may help you on your path to wisdom. just ask him the specifics about the jar command, I'm pretty sure he'll have at least one answer for you.

i make jar file but it when i execute it showing a java exception has occur.

which one?

it doesn't showing any detail it just show a dialog of java virtual machine launcher with the message "a java exception has occurred".

open a command prompt window, change to the folder with the jar file and enter:
java -jar <JARFILENAME>.jar

On Windows: To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd\

C:\>cd bank2

C:\bank2>jar cf myFile.jar *.class

C:\bank2>java -jar myFile.jar
Exception in thread "main" java.lang.NullPointerException
at sun.launcher.LauncherHelper.getMainClassFromJar(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

C:\bank2>

That looks like a problem in the java program. I have not seen that error message before.
What does the manifest file in the jar file look like?
The manifest file must contain a Main-Class: record that points to the starting class for your program.
The jar command you used does not show that you have a manifest file.

here is the content of manifest file

Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build.


note:i have written program in netbean.

That doesn't look like a valid manifest file. Is that what is inside of the jar file?
You need to create a valid manifest file with the Main-Class: line in it and add it to the jar file using the jar command's m option.

please give me some idea about how to create manifest file.

as your manifest file states, it will be automatically generated if you build it using NetBeans, otherwise, you'll have to add a reference to the actual main class:
if you had taken a closer look to the tutorials suggested to you, you would have landed on this and your problem would have been solved by now.

Thanks all, It's working now.

Thankx a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.