Solved

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

Posted on 2014-12-25
3
278 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

770 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