LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 06-29-2004, 01:25 AM   #1
antony_csf
Member
 
Registered: Jun 2004
Posts: 51

Rep: Reputation: 15
Unhappy How to make executetable jar file? if not setting the classpath?


I read some website teaching how to make a executable jar file
my question is how to create a executable jar file with specify the file path

================================================
A simple example. Let's say we wanted to distribute the simple program Hello.java as a JAR. First, we create a text file named Hello.mf which contains:

Manifest-Version: 1.0
Main-Class: Hello

Then, we create the archive by typing:
jar cmf Hello.mf Hello.jar Hello.class Hello.java

and run it by typing:
java -jar Hello.jar

=================================================
then I try to do this


success to make jar and jar can be run anywhere
====================================================
C:\>cd Hello

C:\Hello>c:\j2sdk1.4.2_04\bin\jar cvfm c:\Hello\Hello.jar c:\Hello\META-INF\MANI
FEST.MF *.class
added manifest
adding: Hello.class(in = 401) (out= 276)(deflated 31%)

C:\Hello>c:\j2sdk1.4.2_04\jre\bin\java -jar c:\Hello\Hello.jar
Hello

C:\Hello>d:

D:\>c:\j2sdk1.4.2_04\jre\bin\java -jar c:\Hello\Hello.jar
Hello
=====================================================

It's need to go into the Hello directory to create the jar file!!
my question is if I do not enter to Hello directory. How to specify the command ??

I have try to make the jar outside the Hello directory It make the jar also but exception found

Exception in thread "main" java.lang.NoClassDefFoundError: Hello


thx!
newbie

Last edited by antony_csf; 06-29-2004 at 01:35 AM.
 
Old 07-01-2004, 03:11 AM   #2
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: a few...
Posts: 654

Rep: Reputation: 32
erm ... whoops i completely misread that. sorry

Last edited by chakkerz; 07-01-2004 at 03:13 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up my java classpath in redhat working2hard Programming 9 07-28-2004 10:15 AM
How to make executetable jar file? antony_csf Programming 2 06-28-2004 07:54 PM
setting classpath for java in mdk9.2 perryub Linux - Newbie 2 05-07-2004 04:02 PM
setting java classpath... brutal_brad Linux - Newbie 7 09-21-2003 02:52 PM
setting CLASSPATH variable gabadoo Linux - Newbie 7 01-21-2002 04:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration