Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 39
micro services vs rest web services 16 85
java 8 lambda expresssions exception handling 3 75
Recommendation vb6 to vb.net or others 14 109
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

910 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

21 Experts available now in Live!

Get 1:1 Help Now