How to setup web url for JavaFX documentation? - java

I'm trying to use Eclipse 2021-06 (4.20.0) with an OpenJDK implementation by BellSoft, Liberica JDK 16, that has JavaFX included out of the box. So far, everything goes OK except one rather unpleasant flaw. From Eclipse Java Editor, JavaFX documentation doesn't open in the browser. When I click the "Open attached JavaDoc in a browser" button in the JavaDoc pop-up window for a JavaFX class, the browser tries to open the corresponding URL, for example "https://docs.oracle.com/en/java/javase/16/docs/api/javafx.graphics/javafx/scene/Node.html", but the Oracle server has no page for this URL and shows a Page not found (404) error page.
Apparently, the JavaDoc URL for JavaFX should point to some other location, say "https://openjfx.io/javadoc/16/", but I can't find a way to set it up when JavaFX is included in the system library and Eclipse has the only item "JRE System Library (LibericaJDK-16-Full)" for that library in the project's Java Build Path.
How can I make JavaFX JavaDoc accessible via a browser in this situation?

There is a solution, although not very fast and not very reliable.
In the project properties window (project-> Properties or project-> Build Path -> Configure Buld Path...) one can unfold the system library item and change Javadoc Location for all modules related to the JavaFX so that it points to "https://openjfx.io/javadoc/16/".
I consider this solution not quite reliable because I'm not quite sure that the Javadoc published on openjfx.io exactly matches the Javadoc comments in the JavaFX sources included in Liberica JDK.
Another, more reliable thought somewhat more time-consuming way to solve this issue would be to extract the JavaFX source files from the included zip file, src.zip, generate Javadoc for them and put the link to the generated Javadoc in the above-mentioned properties of the JavaFX modules in the Java Build Path window.

Related

JavaFX Eclipse suggestion to import not present

I am just starting with JavaFX and for some reason, Eclipse does not suggest to import JavaFX stuff so I have to type it in manually. Example: javafx.scene.Group I typed in Group as a type and it suggested other things such as javax.swing.GroupLayout.Group
image of suggestions
I'm not exactly sure, but I think maybe the fact that the JavaFX library is under Modulepath instead of Classpath has to do with it, but it only works if it is under Modulepath.
Help would be greatly appreciated, thanks!
I'm rewriting this answer, as #kleopatra pointed out it was inexact
For suggestions to work, you need to have JavaFX on your project's build path.
If you've created a plain Java project in Eclipse, with a module-info.java at it's source path root, then you need to add all the required jars to the module path:
JavaFX SDK should already be installed on your system, or download it from Gluon and unzip it
Right-click your Java project, got to Build Path -> Configure Build Path...
Go to Libraries tab, point to the Modulepath section
Click [Add External JARs...] button, pick all the jars from JavaFX SDK, hit [Apply and close]
Then suggestions should work as expected, and imports will be automatically inserted at the top of your java files, but they will appear in error the first time you import anything from a given library module, as this module must also be required in your module-info.java. You can do that automatically with a quick fix ("Add 'requires javafx.something' to module-info.java") when hovering the import.
Now there's a more straightforward way to create a JavaFX modular project in Eclipse, using Maven:
Create a new Maven Project
Check and pass the first wizard screen
Select archetype org.openjfx:javafx-archetype-fxml
On the next screen, you can select the JavaFX version of your choice (currently 13 by default)
After the wizard terminates, you've got a nice little project already setup with an application window and two FXML sample displays. You can start from there to build your own project.

How do I enable showing fuction explanation on eclipse? [duplicate]

Using Eclipse I want to view the source code for a core Java class (E.g. java.util.concurrent.ConcurrentHashMap) but when I navigate to the source using 'Open Declaration' it says 'Source not found' and gives me the option to attach the source.
My question is; how do i attach the source? Where do i get the source .jar from for the java.util.concurrent library?
When you are coding in Eclipse, press CTRL and click on any core Java class name in your source. Eclipse will now show a screen saying you don't have the sources installed. However, in this screen there is a link saying "Attach source...". Click that link and import the src.zip file from your JDK installation directory (src.zip). This should do the trick
You need to have the JDK installed. Then you can look in JDK_INSTALL_DIR\src.zip
For me it is C:\Program Files\java\jdk1.6.0_11\ (depends on your current version)
You don't need to get a special open source version.
There are a few good answers here on where to get the source. But a word of caution: I'd be wary about how you use it (if you're using it simply for reference). The API documentation is the only contract you should code against, and is what the developers will keep consistent/intact between releases. I wouldn't use the source find out implementation details and then code my applications with regard to those implementation details, as they may change between releases.
You should be able to see "JRE System Library [jdk1.x.xxxx]" when you look at your project's Java Build Path.
You can access the project build path configuration screen by: right clicking on the project -> Build Path -> Configure Build Path... You should be able to see the JRE System Library entry at the bottom of the list.
The easiest way to view the source for the class is to use the "Open Type" shortcut. The default for this shortcut is: Ctrl + Shift + T". The class you're looking for should appear as you type it's name.
You can go to http://openjdk.java.net/ and download the latest builds of the openJDK project. I think this should give you what you need.
For ubuntu, install openjdk-6-source and use /usr/lib/jvm/java-6-openjdk/src.zip
If you can't find the actual source you can also use a decompiler to regenerate source from the class file.
Personally I use JAD combined with the JADClipse plugin to view source in Eclipse.
Right click on the project -> Build Path -> Configure Build Path.
Now edit your jre > select 2nd option alternate jre -> select any jdk (not jre).
Finish, Now open any class by ctrl + click, Its source code will display.
Outside Eclipse you can see the JDK sources on javasourcecode.org. On this page you can switch from the oficial API documentation to the source code and viceversa.
You can use 'Eclipse Class Decompiler integrates JD, Jad,' from Eclipse Marketplace.
From the find box in the Eclipse Marketplace write: 'jad' and you would find it.
src.zip file is present in installed jdk folder : ..\Program Files\Java\jdk1.8.0_131
Provide this path on the screen showing Attach source... worked for me.
we can see C:\Program Files\Java\jdk1.8.0_73\src.zip
where C:\Program Files is a home directory where I have installed the java.
in eclipse, it will show like Source not found.
form there link will come like browse source.
browse the link C:\Program Files\Java\jdk1.8.0_73\src.zip and attach it. now you can see your source code.
#jjnguy suggestion worked for me. But make sure you have also changed the default compiler as well. Right clickon th project-->Java Compiler->Click on the link under JDK Compliance(right section).

How to make JEE6 javadoc work for a regular JavaSE project in NetBeans 7.0.1?

All I want is for JavaEE6 documentation to show in my JavaSE project. Maybe it's not possible.
The problem is that I created a plain old JavaSE project (i.e. New Project -> Java -> 'Java Application') in NetBeans but I have Java Enterprise Edition elements in it.
One of these elements is the javax.persistence #Basic(fetch/optional) annotation.
- When I press ctrl+space on this annotation, NetBeans says 'Javadoc not found.'. When I use Alt+F1 (Right-Click->'Show Javadoc'), the status bar says: 'Cannot perform Show Javadoc here.'.
Extra info:
1) netbeans_installation_dir\NetBeans 7.0.1\enterprise\docs contains the right API documentation zip file (javaee6-doc-api.zip).
2) I looked around on stackoverflow for similar solutions but they did not work for me - adding the .jar/.zip/folder to the library or via the 'Tools -> Java Platforms -> Javadoc tab' doesn't work neither.
Very strangely enough when I add the javaEE6.jar to the Javadoc tab of the JDK6 platform and in the Project structure window I right click on the 'JDK1.6' library with 'Show Javadoc', a browser window opens and I get to see JEE6 documentation like I wanted.
I'm guessing the problem is that I have a regular JavaSE project and NetBeans can't pick up the JavaEE6 javadoc because it doesn't know my app is partially using EE elements. It's probably also because that documentation is meant for JavaEE6 applications (that's why it's under the /enterprise folder).
So I don't know how to fix this. Is it a bug? (I read on a NetBeans bug report that this could be a possible bug).
This looks like to be a issue with how you are attaching the library to you project. The easiest way to do this, is using the libraries available at Tools > Libraries. You just need to make sure the library you are attaching to your project has the correct Javadoc attached too. If the Javadoc is not attached, you can try the following steps to do this:
In the NetBeans IDE, go to "Tools > Libraries".
Select the correct library and choose the Javadoc tab.
Click "Add ZIP/Folder" and browse to where your project Javadoc is located.
Specify the Javadoc ZIP or folder and click "Add ZIP/Folder".
Click "OK" to close the Library Manager.
More details can be found at [this NetBeans Wiki page][1].

New computer, broken Eclipse

I received my new computer friday and after moving over all of my development projects, my Eclipse "hover" popups have quit working. What I mean is usually when I hover over an element/method/etc... , a small window with the javadoc info will pop up telling me parameters, and a description of the method. Now it just says:
Note: The Javadoc for this element could neither be found in the attached source nor the attached Javadoc.
I've already seen this SO post and tried it. Although I will say there are 15 different packages when you go into preferences>java>installed jre's>edit. All point to an http:// address for the docs.
Also the Android documentation I installed doesn't pull up either (which is what I'm developing for).
Is this with your standard Java classes/methods/etc. or for custom/Android code? I think your problem is because of your installed JRE. You need to download the Java SE 6 SDK from here. The JDK has all of the standard Java classes' source files. Once you have it installed, in Eclipse, go to
'Window'->'Preferences'->'Java'->'Installed JREs'.
Click the 'Add...' button and select 'Standard VM'.
In the 'JRE home' field put "C:\your\path\to\java\jdk1.6_xYourVersionx". It will automatically populate the 'JRE name' field and import all of the necessary jars.
Click 'Finish' and then 'OK'.
If it's a problem with some nonstandard Java code, make sure that you've downloaded the source code. Then,
Right-click on your project and go to 'Build Path'->'Configure Build Path...'.
Select the 'Libraries' tab and expand the entry for your jar file. There should be a sub-entry 'Source attachment: (None)'.
Select it and click the 'Edit...' button and put in your path to the source code.
Click 'OK' and 'OK'.
NOTE: If you've already installed the JDK, you can edit your current JRE to point to the jdk folder instead of the jre folder i.e. "C:\Java\jdk1.6.0_xx" instead of "C:\Java\jre6".
2nd NOTE: Your bit version of Java must match your bit version of Eclipse, so 32-bit Eclipse requires a 32-bit Java, etc.

How do I view JRE's source code in Eclipse?

Using Eclipse I want to view the source code for a core Java class (E.g. java.util.concurrent.ConcurrentHashMap) but when I navigate to the source using 'Open Declaration' it says 'Source not found' and gives me the option to attach the source.
My question is; how do i attach the source? Where do i get the source .jar from for the java.util.concurrent library?
When you are coding in Eclipse, press CTRL and click on any core Java class name in your source. Eclipse will now show a screen saying you don't have the sources installed. However, in this screen there is a link saying "Attach source...". Click that link and import the src.zip file from your JDK installation directory (src.zip). This should do the trick
You need to have the JDK installed. Then you can look in JDK_INSTALL_DIR\src.zip
For me it is C:\Program Files\java\jdk1.6.0_11\ (depends on your current version)
You don't need to get a special open source version.
There are a few good answers here on where to get the source. But a word of caution: I'd be wary about how you use it (if you're using it simply for reference). The API documentation is the only contract you should code against, and is what the developers will keep consistent/intact between releases. I wouldn't use the source find out implementation details and then code my applications with regard to those implementation details, as they may change between releases.
You should be able to see "JRE System Library [jdk1.x.xxxx]" when you look at your project's Java Build Path.
You can access the project build path configuration screen by: right clicking on the project -> Build Path -> Configure Build Path... You should be able to see the JRE System Library entry at the bottom of the list.
The easiest way to view the source for the class is to use the "Open Type" shortcut. The default for this shortcut is: Ctrl + Shift + T". The class you're looking for should appear as you type it's name.
You can go to http://openjdk.java.net/ and download the latest builds of the openJDK project. I think this should give you what you need.
For ubuntu, install openjdk-6-source and use /usr/lib/jvm/java-6-openjdk/src.zip
If you can't find the actual source you can also use a decompiler to regenerate source from the class file.
Personally I use JAD combined with the JADClipse plugin to view source in Eclipse.
Right click on the project -> Build Path -> Configure Build Path.
Now edit your jre > select 2nd option alternate jre -> select any jdk (not jre).
Finish, Now open any class by ctrl + click, Its source code will display.
Outside Eclipse you can see the JDK sources on javasourcecode.org. On this page you can switch from the oficial API documentation to the source code and viceversa.
You can use 'Eclipse Class Decompiler integrates JD, Jad,' from Eclipse Marketplace.
From the find box in the Eclipse Marketplace write: 'jad' and you would find it.
src.zip file is present in installed jdk folder : ..\Program Files\Java\jdk1.8.0_131
Provide this path on the screen showing Attach source... worked for me.
we can see C:\Program Files\Java\jdk1.8.0_73\src.zip
where C:\Program Files is a home directory where I have installed the java.
in eclipse, it will show like Source not found.
form there link will come like browse source.
browse the link C:\Program Files\Java\jdk1.8.0_73\src.zip and attach it. now you can see your source code.
#jjnguy suggestion worked for me. But make sure you have also changed the default compiler as well. Right clickon th project-->Java Compiler->Click on the link under JDK Compliance(right section).

Categories