• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Using PutProperty and GetProperty

 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I wonder if somebody could throw some light onto my problem
I am looking at some code which is about 10 years old
The API under which the program ran appears to have had a method called Properties – this method no longer exists
Some sample code is as follows:-


……………………………

At this stage I get compilation errors – such as
Messages
The method getProperty(String, String) in the type Properties is not applicable for the arguments (String, int)
int, Boolean, double all do not compile

Is there a simple way to correct these compilation errors?
Many thanks
Bob M
 
Saloon Keeper
Posts: 12722
277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me it looks like BM_mod8.properties refers to an object of a custom type that extends the Properties class.

Don't you have access to the source code of the BM_mod8 class?
 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we have the following import



but the dukascopy api no longer lists this ??
 
Marshal
Posts: 72048
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have some sort of XXX.html documents emitted from javadoc Properties, I presume?
 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no - afraid not
 
Saloon Keeper
Posts: 23259
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I can see, they completely re-designed the entire library, but kept the same package name.    Classname styles are now completely different (more like Microsoft OLE).

You may have some major rework ahead of you.

 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks for your helpful comments

Bob M
 
Bartender
Posts: 2828
149
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if you don't have access to the source, the following command will work for you: where "foo.bar" is the package name. This would list out all the package/protected/public classes and members for the given class. Look specifically all the methods having "get" in the name and you might find a suitable candidate.
 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Salvin

I am sorry but I don't understand what you are telling me

Bob M

 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
           

the above code is OK since both arguments are strings

         

but this line of code - no - since arguments are string and iint

Bob M
 
salvin francis
Bartender
Posts: 2828
149
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if javap does not work it means that the system path is not configured to point to the java bin folder. Check the folder where java is installed, you should see a bin folder having the javap command in it.

For the code, you can try to do the following: This converts the number or a variable into a String.
Have a look at this: https://docs.oracle.com/javase/tutorial/java/data/converting.html


 
Master Rancher
Posts: 4180
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On my system, javap.exe is found in the bin folder for the JDK.

The locations on my PC:


Found java.exe in:
 C:\Program Files (x86)\Common Files\Oracle\Java\javapath\           10/28/19 12:02 PM
 C:\ProgramData\Oracle\Java\javapath\                                06/01/18 12:33 PM
 C:\Program Files\Java\jdk1.8.0_60\bin\                              09/18/15 08:58 PM
Found javap.exe in:
 C:\Program Files\Java\jdk1.8.0_60\bin\                              09/18/15 08:58 PM

 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Salvin - it is the



line of code that doesn't compile

The put command seems OK
         
 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Norm -  I have jre on my computer not jdk
 
Bartender
Posts: 7768
70
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something is missing here. In your first post you say you are having compilation problems, but now you say you don't have a JDK but only a JRE. A JRE does not come with a compiler. ???
 
salvin francis
Bartender
Posts: 2828
149
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Matthews wrote:... line of code that doesn't compile...

I see it now, I have a typo in my code. Having said that, my previous answer should give you a clue about how to use String.valueOf to convert the number to String.
It also points to a tutorial about different ways to do it.

As a side note, programmers are considered as power users. They no longer merely use the computer, they command it in a language it understands. To be a power user, you need to understand how system commands work, what is the setup for your system, the installed software and so on. The posts above are giving me a scary picture. It looks like you are looking for a set of changes to somehow make someone else's code compile and run. I suggest being understanding how stuff works before diving into coding.
 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
compilation is done on the dukascopy platform

I have used the string,valueOf command to convert an integer into a string before

my problem is finding a solution to replace the get command which caters for (string, int), (string, boolean), (string, double) to which I now don't have access to
 
Norm Radder
Master Rancher
Posts: 4180
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the problem that you have source code with the wrong datatypes for the arguments being passed to the get... methods?
Can you change the source code so that the arguments match what the compiler wants?
 
salvin francis
Bartender
Posts: 2828
149
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Matthews wrote:compilation is done on the dukascopy platform

I am afraid, haven't heard of this platform. Is it some kind of cloud based service or similar?

Bob Matthews wrote:I have used the string,valueOf command to convert an integer into a string before ... my problem is finding a solution to replace the get command which caters for (string, int), (string, boolean), (string, double) to which I now don't have access to

The valueOf method will work for other datatypes such as double or long or even boolean. This is also demonstrated in the oracle tutorial I shared earlier. Adding link again for reference: https://docs.oracle.com/javase/tutorial/java/data/converting.html

If you are able to inject your class into the code, you can use Generics to solve this issue. Something like this will work: However, I suggest learning the language basics a bit more before you dive into advanced topics such as generics. The above code is just an example and does not completely reflect your exact usecase.
 
Bob Matthews
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Salvin

Dukascopy is a Swiss Trading Bank where you can trade currency pairs, stock, gold, etc.

Thank you for you advice

Bob M
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic