Solved

Is it possible to read the properties file from a jar file?

Posted on 2014-12-25
3
329 Views
Last Modified: 2014-12-28
Hello,

I was just wondering if it was possible to read the properties from a jar?

I tried searching online; but I might have confused google with the keywords...

Appreciate any help on this!
0
Comment
Question by:Errang Genevre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 100 total points
ID: 40517952
What do you mean by "properties", and what does this question have to do with Python? Is Python the language you are using to try and do the read?
0
 

Author Comment

by:Errang Genevre
ID: 40518064
Yes, sorry... forgot to mention that part.

I'm trying to see if its possible to use Python to read from a jar file; rather than having a Java class that just extracts the data from the jar file.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 400 total points
ID: 40518108
Java jars are just specially formatted zip files.  So yes, you can open and read jars from python.  See the documentation on zipfile (https://docs.python.org/2/library/zipfile.html).

import zipfile
with zipfile.ZipFile("jython.jar", "r") as jar:
    with jar.open("jline/windowsbindings.properties", "r") as property_file:
        for line in property_file:
            print(line)

Open in new window

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This is about my first experience with programming Arduino.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question