Link to home
Start Free TrialLog in
Avatar of kgreddy
kgreddy

asked on

How to use JAR file in Application?

Hi,

I am new to Java. I am using Visual cafe Version 3.
I have downloaded an application which is
available as .jar file.

Now, I have to write a small swing based GUI where I
have lo create a button (apart from many other things)
by clicking on this button I should be able to invoke the
application I have downloaded.

Is this possible.
Please guide me in doing this.
Thanks in advace.

Regards.
Avatar of vladi21
vladi21

Java Tip 49: How to extract Java resources from JAR and zip archives
http://www.javaworld.com/javaworld/javatips/jw-javatip49.html

Java Tip 70: Create objects from jar files!
http://www.javaworld.com/javaworld/javatips/jw-javatip70.html
ASKER CERTIFIED SOLUTION
Avatar of meming
meming

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
java -jar <jarname>
Avatar of kgreddy

ASKER

meming:

Yeah, I could get the information about the main class.
But not the arguments I have to pass.

I tries doing this :
Say I have my .jar file in c:\jCVSFiles\jCVS-5.1.1\application\jcvsii.jar

I have set my CLASS path in autoexec.bat and rebooted my system
to get this information.

Now, I tried java -classpath c:\jCVSFiles\jCVS-5.1.1\application\jcvsii.jar <Main Class>

I am getting the following error.
Failed reading value of registry key.




Avatar of kgreddy

ASKER

meming:

Yeah, I could get the information about the main class.
But not the arguments I have to pass.

I tries doing this :
Say I have my .jar file in c:\jCVSFiles\jCVS-5.1.1\application\jcvsii.jar

I have set my CLASS path in autoexec.bat and rebooted my system
to get this information.

Now, I tried java -classpath c:\jCVSFiles\jCVS-5.1.1\application\jcvsii.jar <Main Class>

I am getting the following error.
Failed reading value of registry key.




In case you don't have a complete jCVS package, download it from http://www.ice.com/java/jcvs/.

First, check the requirements document of your copy of the jCVS. Install all the required software packages on you machine, including JDK/JRE 1.1 or 1.2, Swing 1.1, JAF, and JavaHelp (see c:\jCVSFiles\jCVS-5.1.1\doc\manual\misc\require.html). JDK/JRE can be found at www.javasoft.com.  You only need JRE if you won't program in Java.

The error message you have sounds like an improper Java installation to me (just the java.exe program alone can't do the trick).

Next, read through the documents carefully to find an example of how to start the program.

You don't have to modify the autoexec.bat file and reboot to have the correct classpath setup. The "-classpath" option of the java.exe program is all you need to have a very controlled environment for your program:

java -classpath c:\jCVSFiles\jCVS-5.1.1\application\jcvsii.jar;%jar_file1%;%jar_file2%;%the_rest% com.ice.jcvsii.JCVS <try no args first>
(the classpath takes jar file name, ie ..\a.jar, and class file path, ie ..\jcvsClasses)

As I understand, jCVS is a GUI application. It may not require any command line arguments.