This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!

sushobhan bhaumik

Greenhorn
+ Follow
since Jan 23, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sushobhan bhaumik

Stephan van Hulst wrote:It's definitely wrong if you're trying to add other dependencies to your JAR.

Why do you need to modify an existing JAR? Can't you build a new one?

Honestly, it sound to me that you can save yourself a lot of pain if you learn some Maven and use the source and the assembly build plugins.



yeah even i ma thinking to proceed with maven to build a jar, but will it work in jaspersoft server if i place same jar in jaspersoft lib folder?
2 weeks ago

Campbell Ritchie wrote:Please explain step 3 more. Your description is not clear, and that step might be wrong.



I have and existing jar.
in that some class files are there in com.package folder
it has one lib folder
it has one manifesto file


i have created 3 java files.
will convert these class and paste in this jar.
will add dependency jar in lib folder.


2 weeks ago

Stephan van Hulst wrote:You can use the jar tool to create a new JAR or to add files to an existing JAR.

Note that a JAR file uses the ZIP compression format, so you can also add files to an existing JAR using any ZIP tool you like.



Hi,

i am using following steps:

1.compiling java files to get .class files
2. opening existing jar using 7zip
3. copying .class files in packages and jackson jar in lib folder.

please let me know my steps are correct or not.

thanks in advance

2 weeks ago

Stephan van Hulst wrote:Okay well, first of all, you shouldn't have any reason not to trust that the Java compiler doesn't correctly compile .class files from your .java files. Secondly, when you decompile code, you will never get the original code back. And depending on how you used the decompiler (which you still haven't told us yet) you may only get class and method signatures, and not method bodies.

Anyway, decompilation is not needed.

To add sources to a JAR, you would use the jar command line tool and specify the source folder with the -C switch, the same way you specify the compiled code folder with the -C switch. An easier option is, if you're using Maven, to use the Apache Maven Source Plugin. It will add sources to your build artifact for you.




So in the existing jar I can add my files right I. E those three files. Using above mentioned command?
2 weeks ago

Stephan van Hulst wrote:Okay well, first of all, you shouldn't have any reason not to trust that the Java compiler doesn't correctly compile .class files from your .java files. Secondly, when you decompile code, you will never get the original code back. And depending on how you used the decompiler (which you still haven't told us yet) you may only get class and method signatures, and not method bodies.

Anyway, decompilation is not needed.

To add sources to a JAR, you would use the jar command line tool and specify the source folder with the -C switch, the same way you specify the compiled code folder with the -C switch. An easier option is, if you're using Maven, to use the Apache Maven Source Plugin. It will add sources to your build artifact for you.



ok i will, try to generate jar using that and update in the forum after that. thanks for all your help, actually i was little bit worried thats why
2 weeks ago

Stephan van Hulst wrote:Please answer 2) and 5).



2.using java decompiler
5.to see class file contains proper line of codes or not.
2 weeks ago

Stephan van Hulst wrote:Can you please give direct answers to these questions?

1) Are you decompiling the .class files?

2) If the answer to question 1 is yes, what command are you using?

3) Do you need to add the .class files to the JAR?

4) Do you need to add the .java files to the JAR?

5) If the answers to questions 1 and 4 are yes, then why are you decompiling the .class files instead of just adding the original .java files?



1. yes
3.yes
4.yes.

but how to add these class or java files into that jar?
2 weeks ago

Dave Tolls wrote:Where are you gettig the code for this from:
PriceListUtil$1
?

I can only assume you are decompiling the class file?

If so, why?



yes i am getting from $file only, actually, my requirement is to add these java files in existing jar file.

so struggling to copy this pricelist class file in that jar.
2 weeks ago

Stephan van Hulst wrote:A class file doesn't contain lines. It's a binary format and contains byte code. So if you managed to get code from it, you did it by decompiling it, which may only yield class headers, depending on the arguments you used.

So, what did you do to get lines of Java code from a .class file?



so to create jar with these files, which approach i should follow?
2 weeks ago

Dave Tolls wrote:If you compile PriceListUtil, then the following line:

will produce an anonymous class (for the TypeReference).
That anonymous class will be in a class file called PriceListUtil$1.class.

Not sure where you pulled that code for it from?



yes correct, typereference is present in jackson-core jar file.
I am using this file to parse my json tree.
but why its not showing other lines in the class file?
2 weeks ago

Stephan van Hulst wrote:What do you mean by generated? What are you generating it from? And how?



Hi actually i need to create a jar with this, so while generating class file for priceutil its not giving me full class file.
2 weeks ago
I have three java files, SizeRange, SizePrices is getting generated properly, but when i am generating pricelistutil file i am getting below .class only.can anyone please help me on this?

I need to create a jar file with these three files.


{}








[/code]
2 weeks ago
Now instead of static json i am passing json like this as a parameter.



what all changes i need to do then, please help me in this..almost most of the things are done.
2 weeks ago
Hi ,

after adding below code i am able to get read the json.

collection = mapper.readValue(json, MyClassName.class);

then i am grouping by cargo price



now i am getting a map with list of sizes where price is matching, then how i can get the range?
2 weeks ago

Ron McLeod wrote:

sushobhan bhaumik wrote:after adding that dependency i am getting same issue ...


Please post your POM and code for the class where you are using ObjectMapper.



Hi now after executing getting below error.


Not able to upload file so pasting here

POM file:



java file:

2 weeks ago