Solved

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

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

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
for i loop in grovy 1 32
Installed softare without GUID 6 53
Java and GPO 11 45
compre toata in where clue oracle 4 39
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now