Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@taq
Copy link

@taq taq commented Jun 23, 2016

Hi!

I just created an Apache Ant build file to create a JAR file with all the classes compiled inside of it. This way we can easily compile and build using our current Java version. Just install Apache Ant (if not already installed) and type:

$ ant

to create the JAR file. I also added a .gitignore file to ignore the compiled classes under the created dir, and also the created JAR file, we don't need them on the repository. Also, I renamed the README file to README.md to make sure it is recognizable as Markdown, and made some formatting improvements on it.

Thanks for your code! :-)

@johnjaylward
Copy link
Contributor

or you can just call javac *.java and jar cfv json-java.jar *.class

@taq
Copy link
Author

taq commented Jun 23, 2016

Hey, thanks for the answer!

That will work for sure, if you don't need the package (org.json) on internal directories of the .jar file. Doing exactly what you pointed will give me the following structure:

 $ jar tf json-java.jar 
META-INF/
META-INF/MANIFEST.MF
CDL.class
Cookie.class
CookieList.class
HTTP.class
HTTPTokener.class
JSONArray.class
JSONException.class
JSONML.class
JSONObject$1.class
JSONObject.class
JSONObject$Null.class
JSONPointer$Builder.class
JSONPointer.class
JSONPointerException.class
JSONString.class
JSONStringer.class
JSONTokener.class
JSONWriter.class
Property.class
XML.class
XMLTokener.class

Using the Apache Ant task provided, I get:

$ jar tf JSON-java.jar 
META-INF/
META-INF/MANIFEST.MF
org/
org/json/
org/json/CDL.class
org/json/Cookie.class
org/json/CookieList.class
org/json/HTTP.class
org/json/HTTPTokener.class
org/json/JSONArray.class
org/json/JSONException.class
org/json/JSONML.class
org/json/JSONObject$1.class
org/json/JSONObject$Null.class
org/json/JSONObject.class
org/json/JSONPointer$Builder.class
org/json/JSONPointer.class
org/json/JSONPointerException.class
org/json/JSONString.class
org/json/JSONStringer.class
org/json/JSONTokener.class
org/json/JSONWriter.class
org/json/Property.class
org/json/XML.class
org/json/XMLTokener.class

The latest seems to be the "official" way to create .jar files with package names defined on the source code [1][2][3] and make it easier to create it, of course, if you use Apache Ant. ;-)

[1] http://www.ntu.edu.sg/home/ehchua/programming/java/j9c_packageclasspath.html
[2] https://newcircle.com/bookshelf/java_fundamentals_tutorial/packaging
[3] http://kevinboone.net/classpath.html

@johnjaylward
Copy link
Contributor

The release project already handles the packaging paths. If you read the FAQ you will see that we don't want build tool integration in this project.

@taq
Copy link
Author

taq commented Jun 23, 2016

Uh, ok so. But I have a point on the internal directory structure! ;-)
You can close the pull request, I'll keep the Apache Ant build file on my fork. :-)
Thanks!

@stleary
Copy link
Owner

stleary commented Jun 23, 2016

@taq, thanks for the pull request. As discussed, this project has a longstanding policy of not supporting any particular build tool, so the PR cannot be accepted. However, I think you made a valid point. Furthermore, new users may be puzzled about how to build their own jar file. Please feel free to add wiki text explaining how to correctly build the code, using whatever build tools you think appropriate. At the present time, the wiki pages should be open for editing by any interested party.

@stleary stleary closed this Jun 23, 2016
@johnjaylward
Copy link
Contributor

@taq, The maven version is maintained by @BGehrels and can be found in the https://github.com/BGehrels/JSON-java repository if you are interested. This is what is used to release to maven-central

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.