B4J Tutorial B4Xsources: a B4X source code viewer using command line tools to extract and decompile the files.

In this tutorial you can learn how to extract files from a B4Xlib or Jar file.
1678873413355.png

You can select in the file menu the library type to open and extract.
1678873453507.png

For each library type there is a folder (b4xlibfiles and jarfiles). The extraction process creates a folder in these library type folders with the same name as the library. The files from the library are extracted in this folder using the command line tool 7za.exe.
1678873501596.png

When you click on the (blue) library name you can expand or collapse the list of files.
When you click on a filename then that file will be opened in a tab page from the right pane.
The source code is displayed and a summary web view is available for *.bas and *.java files.
1678873564005.png

This summary is a filter from the source code and shows the available methods or subroutines.
1678873596247.png

When you click on a *.class file (from a Jar library) then that file is decompiled using the commandline tool jd-cli.jar. The resulting file is a *.java file that replaces the *.class file in the list. You can find the resulting files in the folder c:\users\<your name>\AppData\...
1678873627577.png

The *.xml file that usually accompanies the *.jar file is NOT automatically copied to the library folder. This *.xml file is not always updated and it will only confuse you. You can however view the file after you have copied it.
1678873672929.png

You can view files with the following extensions:
".txt",".html",".bas",".b4a",".b4i",".b4j",".xml",".java",".css",".MF",".SF",".js",
".b4x_excluded".
Reading the source code of the B4X programming language can help you find answers to your questions.
Learning from the B4X programmers can help you improve your programming skills.
You can find the source code here: B4XSources.zip
Happy coding!
 

AnandGupta

Expert
Licensed User
Longtime User
Few years ago when there was no b4xlib, we used these and more tools, available in the forum, to de-compile .jar and study the .java codes.
Now we do manual zip extract of b4xlib, but your tool is best of both world šŸ‘
Thank you.
 

aeric

Expert
Licensed User
Longtime User
we used these and more tools, available in the forum, to de-compile .jar and study the .java code
I don't know there are such tools exist in this forum. You mean other forums?



Disclaimer: I have no intention to start a debate or war.

My opinion towards compiled jar is that compiled library (.jar) is not for decompilation by other people without the permission of the original author. I am not sure what it means by the sake of study the Java code.

You are not allowed to decompile libraries unless you have explicit permission from the library author.

Make sure you get permission from the author before doing that. Otherwise I think this is unethical.
 

PaulMeuris

Active Member
Licensed User
1. You should inform yourself about the license being used on the forum when you publish a library there (creative commons?)
2. You should get permission from the author of the library to de-compile it when you obtained the library from another source.
3. This tool should be used for studying purposes only!
Please start another thread if you want to debate about the license.
 

alwaysbusy

Expert
Licensed User
Longtime User
1. You should inform yourself about the license being used on the forum when you publish a library there (creative commons?)
2. You should get permission from the author of the library to de-compile it when you obtained the library from another source.

The creative commons license can be overridden if another license is included. So even if you get it from this forum you should still explicitly ask permission to the author to de-compile if it is prohibited by his license.

The full statement of @Erel is:

By default libraries created and shared by forum members are licensed under creative commons CC BY 3.0 license: Creative Commons &mdash; Attribution 3.0 Unported &mdash; CC BY 3.0

Developers can choose a different license if they desire.

Or to be crystal clear about my distributed libraries on this forum:

Freeware/Donationware License

B4J is Copyright (c) 2010 - 2022 by Anywhere Software All Rights Reserved.
LIBRARY (Library/library): B4J library files BANano.jar and BANano.xml (by Alain Bailleul)
SOFTWARE (Software/software): Computer Software
APPLICATION (Application/application): Any end product as the result of compiling with an Anywhere Software product
SOURCE CODE: human-readable program statements written by a programmer or developer in a high-level or assembly language that are not directly readable by a computer and that need to be compiled into object code before they can be executed by a computer

BY USING THIS LIBRARY, YOU AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE.

1. THIS LIBRARY IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER/AUTHOR/DEVELOPER BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,SPECIAL,INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY INCLUDING BUT NOT LIMITED TO LOSS OF DATA, FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER PROGRAMS OR LIBRARY, EVEN IF COPYRIGHT HOLDER/AUTHOR/DEVELOPER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

2. YOU MAY NOT COPY, SUB-LICENSE, REVERSE ENGINEER, DECOMPILE, DISASSEMBLE, OR MODIFY THIS LIBRARY IN ANY WAY.

3. YOU MAY NOT DISTRIBUTE THE LIBRARY ON ANY MEDIUM WITHOUT PRIOR NOTICE FROM ALAIN BAILLEUL ([email protected]). YOU HAVE TO ASK FOR PERMISSION IN ORDER TO MAKE THIS LIBRARY AVAILABLE FOR DISTRIBUTION OVER THE INTERNET OR ANY OTHER DISTRIBUTABLE MEDIUM.

4. YOU AGREE NOT TO DISTRIBUTE FOR A FEE AN APPLICATION USING THE LIBRARY THAT, AS ITS PRIMARY PURPOSE, IS DESIGNED TO BE AN AID IN THE DEVELOPMENT OF SOFTWARE FOR YOUR APPLICATION'S END USER. SUCH APPLICATION INCLUDES, BUT IS NOT LIMITED TO, A DEVELOPMENT IDE OR A B4J SOURCE CODE GENERATOR.

By possessing and/or using this library you are automatically agreeing to and show that you have read and understood the terms and conditions contained within this Freeware Software License Agreement. This Freeware Software License Agreement is then effective while you possess, use and continue to make use of these software products. If you do not agree with our Freeware Software License Agreement you must not possess or use our library products - this Freeware Software License Agreement will then not apply to you. This Freeware Software License Agreement is subject to change without notice.

Violators of this agreement will be prosecuted to the full extent of the law.

This library is free, however if you do enjoy it, please consider a donation to Alain Bailleul ([email protected]) for his time and efforts to make this library possible.

This license file (LICENSE.TXT) shall be included in all copies of the library or any distribution using the library in any form resulting from mechanical transformation or translation of the source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.

If you have any questions regarding this license, please contact [email protected]
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Please start another thread if you want to debate about the license.
Hi Paul, I appreciate your work and tools you created.
I just wish to give a gentle reminder to other members which happen to ignore the intellectual property of people putting effort in their projects. Nothing about this project posted #1. Sorry for out of topic.
 

AnandGupta

Expert
Licensed User
Longtime User
I agree. @PaulMeuris has created another master piece and is humble enough to give us the source codes.
How we use it is not in his control. It is same for a knife. In the hand of a doctor it can save a life.

Thank you Paul šŸ™
 
Top