Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

packaging a JAR file

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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�.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic