Java look into API method - java

Is there a way to look into originally given methods by API?
I am a beginner in programming and sometimes feel like taking huge shortcuts when using given methods and not really having an idea what tools i would use if i had to write it on my own.
Thanks in advance for given advices.

You want to look into Java code?
Here is a snapshot to attach java documentation and source code
Click Windows
Click Preferences
Click Java
Click Installed JRE
See the image for more steps

After you clarified your question, I think I can suggest you a solution. Let's suppose that you want to see what java.util.Collections.reverse(List list) do! When you downloaded the JDK you downloaded the sources too. You can find it here (or else to where you placed) for example for JDK8: C:\Program Files\Java\jdk1.8.0_66 => src.zip In this zip file you can find \java\util directories and inside this you can find Collections.java and inside this you can find the reverse(List list) method in JAVA source format. (Anyway, you can find the bytecode of this example method too in the rt.jar...but I think you shouldn't bother yourself with it if you are a beginner.) I hope I could help.

Related

How can I view Java 10 Javadocs (in Eclipse)

Firstly, I do realize this question has been asked in many permutations all over stackoverflow. I searched quite a bit before posting, so please don't link to another SO question unless it answers my specific question and scenario.
I recently upgraded from Java 8 to 10. Now, however, I cannot view source or javadocs for any Java class or library. Makes coding a lot more cumbersome.
How can I attach the source and/or javadocs for Java 10, either OpenJDK's version of it and/or Oracle's? I've read other questions' answers about needing to download them separately, opening up the Installed JREs options section in Eclipse, and manually pointing Eclipse to the source/javadocs location.
I cannot find Java 10 javadocs for download, although I was able to find the Javadoc HTML page. I cannot find specific questions about Java 10, only Java 6/7/8/9.
I cannot find Java 10 javadocs for download
I think this one is what you're looking for:
http://www.oracle.com/technetwork/java/javase/documentation/jdk10-doc-downloads-4417029.html
Step 1: Window --> Preferences --> Java --> "Installed JREs"
Step 2: Select the jre and click edit.
Step 3: Select as shown in the screenshot and provide the source by selecting source attachment.
Step4: Click the external file and give the source for zip file "Src" as shown below. And click ok.
Step5: Provide java doc location https://docs.oracle.com/javase/10/docs/api/ as shown below.
Step6: Click Ok and Click apply and close and you are good to go.

IInAppBillingService.java does not generate Java file in Android Studio

I am following this tutorial:
https://developer.android.com/google/play/billing/billing_integrate.html#billing-permission
No InAppBillingActivity file is generating. I'm not sure why. I checked to make sure everything is placed correctly but no luck. Here is what my folder structure looks like:
Click this for picture
Now I know there are similar questions like this but none of them were able to solve my problem. I have already imported googles billing library as well. No file generates when I run / build the app.
The problem is that the docs are not very accurate in specifying where it is that you will find the java file that should be in the gen folder. I had faced the same problem and had broken my head over it, until I found that the .java file was infact generated and it was in the path :
\app\build\generated\source\aidl\debug\com\android\vending\billing\IInAppBillingService.java
Its not a headache issue and your code runs smoothly itself without any interventions required. Hope this helps!
In android studio double click on your package name:
click in New and then on AIDL
Hope it helps
Its usually generated but not put where the tutorial tells you. If you do a Ctrl+N and type in the class name in intelliJ you may be able to find it

Use of Erfc function: commons.apache.org library

My problem is simple: I would like to use the error function Erfc(double) in Java with Eclipse but I do not want to implement it (because it is complicated).
So, I have found this:
http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/special/Erf.html
That does exactly what I want. The problem is that I can not use it. As it is not from "docs.oracle.com", I can not just import it. But unfortunately, I can not include the library and use it neither because what I download from :
http://commons.apache.org/proper/commons-math/download_math.cgi
is not a .jar
Does someone know how to "install - use" it?
I use Ubuntu 12.04 on a Intel® Core™ i7-3610QM CPU # 2.30GHz × 8 and my IDE is ecplipse.
Ok, this was a stupid question! So I have found the answer by myself.
I just needed to download the binary files and add it as a .jar. Then it works as a classical library.
To use it, I must
import org.apache.commons.math3.*;

ERROR: Does not contain source for Thread.class - Class File Editor

First time post, long time watcher. Can't wait for my classmates to read this (they use the site too)
I am using Eclipse Juno w/ Java SE 1.7
I am having an eclipse problem. It doesn't happen all the time, typically only during File IO. I'm using my debugger perspective in Eclipse to try and trouble shoot some problems (its really a simple program).
UPDATE: Apparently new users are not allowed to upload screen shots. If you could take the time to click on the link to witness my problem I would appreciate it.
Screen Shot Link (not java code):
imgur.com/5IxI3.png
As you can see I am getting an odd thread.class problem. I have even reinstalled java. Could it be something with my code as well then?
Thanks for anyone who offers input or helps in anyway. I do have about a week before this is do so I'm not just looking for free answers, just frustrated. Thanks!
If I understand your question correctly, you need to attach source because Thread is API class.
Download Java source (not binary exe file) from Oracle
Go to eclipse Yourproject --> Properties --> Java Build Path >
Libraries and expand JRE System Library --> jre version--> rt.jar.
Select Source attachment ---> Point to the down loaded source.
Read this tutorial for more info.

String cannot be resolved to a type - Java RAD

I've recently started developing in Java (coming from .Net). The IDE I am using is RAD 7.3.
After importing a project, which I need to do some enhancements on, I am receiving this error:
"String cannot be resolved to a type"
This applies to all variables of the String data type, as well as any methods that take string arguements. I'm very inexperienced with Java so I'm not sure how to go about fixing this. My guess is that it has something to do with the way RAD was installed, and that required libraries are missing. Again, not sure how to address that.
Any help or guidance would be much appreciated! Thank you
My guess is you miss the JRE Runtime Library in your project. But this would cause all the java.* classes to generate this message! Can you post your code so we can see what might be the problem?
try doing :
right-click on your project.
->properites
->java Build Path
->tab Librairies
check if the JRE System Library is there.
i am a beginner. i am using Eclipse and got stuck at the Hello World code. Got same error description and also error stating can't resolve 'system'.
After staying frustrated for few hours, as I checked JRE library path and stuff, I just Capitalized 'S' of 'string' and 'system'.. and bang.. problem solved. I hope this helps.
I don't know if this helps anyone, but here I go.
I had the same problem just now in Visual Studio Code (I am on Linux). On my java.home, I had the options in my directory of:
/usr/lib/jvm/java-8-openjdk-amd64
/usr/lib/jvm/java-1.8.0-openjkd-amd64
I had the first one as default, but when I switched to the second one, it all started working properly.
You need to capitalize the "s" in the string.
Another way to solve this problem is in the following way.
Right click on the project-->properties-->Java build path-->go to the
library option
and delete or remove the library that is in error, after this you select add library and download the library that you deleted and ready.
error- string cannot be resolved to a type
Here in the declaring the method "string" in bold is lower case.
Change string to upper case.
Example:
public static string howManyPass(double grd1, double grd2) {
}

Categories