• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

packaging a JAR file

 
Itapaj� Takeguma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello there,
1)
To run my server aplication I must do java -Djava.rmi.codebase.... ServerFrame server

I think my self how can I creat a JAR file where the user types:
java -jar server if I have to type -Djava...??

2)
another question: if I have a java.properties file in the current directory how can I access this file when it is inside the jar file? I can only access the properties file when put a copy outside the jar file.

thanks,
Itapaj� Takeguma.
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) The user would type java -jar -Djava.rmi.server.codebase=......Server

2) Why does the properties file need to be in the jar file ?
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
InputStream is = getClass().getResourceAsStream(myPropertiesResourceInMyJar);

myProperties.load(is);
 
Itapaj� Takeguma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the assignment says the user will type java -jar server and not java -jar -Djava... server !
(assignment) java -jar <path_and_filename> [<mode>]

and I think that if the property file stay inside the jar, it seens to me more clean. my readme does not have to say "unpack the java.properties file to the current directory...".

thanks guys,
Itapaj�.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11886
198
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Itapaj�,

If you start the RMI Registry programatically from within your application then it will already know the base path structure to your classes, and you will not need to specify the codebase on the command line.

The user's options should be persisted to the properties file - you may find that challenging if the properties file is inside the jar file.

Regards, Andrew
 
Itapaj� Takeguma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andrew Monkhouse:
Hi Itapaj�,

If you start the RMI Registry programatically from within your application then it will already know the base path structure to your classes, and you will not need to specify the codebase on the command line.

The user's options should be persisted to the properties file - you may find that challenging if the properties file is inside the jar file.

Regards, Andrew


I've never hear about start RMI regitry programatically, could u tell where I can find some reference?

One more thing, should or shouldn't I hava a properties file? If I have some default string may I simply do:
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11886
198
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Itapaj�,

I've never hear about start RMI regitry programatically, could u tell where I can find some reference?


Take a look at the java.rmi.registry.LocateRegistry class, particularly the createRegistry(int port) method.

One more thing, should or shouldn't I hava a properties file? If I have some default string may I simply do:


Check your instructions. Some instructions require you to save all the user configurable options to a properties file in the current working directory.

Even if your instructions don't require this, you may want to consider it anyway. It will make the system much more user friendly.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic