How to see source code of JavaFX SDK in eclipse kepler? - java

I decided to learn JavaFX. I need to browse source code of classes like javafx.scene.layout.StackPane .
So I pressed F3 to go to source code. There is no source code and no button that allows to attach source code.
I looked in the Internet and din't find anything helpful.
I use eclipse kepler and java7.
I have jfxrt.jar in my classpath.

For Java SE 8, the JavaFX source code is distributed with the JDK. If Eclipse does not pick it up automatically, you need to select the zip file using the standard "Attach Source" approach. The file is called javafx-src.zip and is located alongside src.zip in the root of the unpacked Oracle JDK (on Windows).

Recommended - use Java 8 + e(fx)clipse
I believe if you use the recommended e(fx)clipse plugin for JavaFX development and a recent Oracle (Java 8+) JDK, then the Eclipse IDE will automatically be configured to be aware of the JavaFX sources.
Otherwise manually attach sources
If this doesn't work for you, then you can follow JodaStephan's suggestion of attaching sources manually.
For Java 7 users
If you must use Java 7 rather than Java 8, then full source won't be available as JavaFX was only fully open sourced for Java 8. However, you can view some of the source by manually downloading the source code as described at: Where can I download the JavaFX 2.2 source code?, then manually attaching sources. I do not recommend use of Java 7 for JavaFX development or runtime as there were many bug fixes and improvements in Java 8 which are not ported to Java 7.
Disclaimer
I'm not an Eclipse user and haven't tried some of these options.

Related

NetBeans: "Failed to automatically set-up JavaFX Platform"

I have been troubleshooting this error for the past few days - and have hit a brick wall. I am running NetBeans v11.3, and Ubuntu Bionic (v18.04.4).
I have installed Java versions 8 and 11 (openjdk) along with source code.
I have also installed javaFx versions 8 and 11 with source code.
I have even gone to "Tools -> Java Platform Manager" and ensured that v8 and v11 of Java are properly installed along with the appropriate "Platform Sources".
But I still get the error mentioned when I try to create a new JavaFX project.
Any help would be very much appreciated.NetBeans JavaFX project create error
I have never tried to use JavaFX on openJDK, try out with Oracle JDK, as far as I know this is the best choice for using JavaFX, also try to edit the default platforms to match the appropiate system paths

can not use javafx on intellij idea

I have problem importing import "javafx.util.Pair" into my program.
after searching the net I've found this answer cannot resolve symbol javafx.application in IntelliJ Idea IDE and I've installed desired jar file but still I've problem to import.
this is what I face to when open java jdk.
I don't know the why the "jfxrt.jar" is different.
note the black arrow on the folder icon
open the File | Project Structure dialog, there under Platform Settings select SDKs and then your JDK 1.8. On the right you then see all the jars that make up the classpath to your SDK. Make sure that your jfxrt.jar is in that list, if not, you can add it by clicking the '+' button at the bottom.
Update May 2020
JavaFX is no longer part of the Oracle or OpenJDK default distributions. Instead it is available as a seperate library or module set.
For instructions on using JavaFX in your application, see the documentation at:
https://openjfx.io
For instructions on working with a modern JavaFX installation and Idea, also see the related question:
IntelliJ can't recognize JavaFX 11 with OpenJDK 11
You don't need to "install the desired jar" (whatever that means).
You don't need to do that for JavaFX. You should not do anything explicitly with jfxrt.jar either in the filesystem or by adding it to a project classpath. If doing something on the filesystem, that is especially bad as jfxrt.jar is not made to be standalone and requires related native libraries shipped with the JDK in order to work.
The JavaFX code should be part of the JDK installation you are using. Perhaps you are using a Java version below 8 or an OpenJDK implementation that does not include JavaFX. If so, then install the Oracle JDK 8+ and set idea to use it. Everything should just work then and all of related JavaFX imports will resolve.

JMonkeyEngine with JDK 8

I want to use lambda expressions, so i need JDK 8. I have set the project to JDK 8, in properties, but editor of the code gives errors when i use lambda. When trying to build it gives error like this:
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Test.java:17: error: lambda expressions are not supported in -source 1.7
Runnable r = () -> System.out.println();
(use -source 8 or higher to enable lambda expressions)
So how to set JMonkeyEngine working on JDK 8?
Thanks.
I wasn't able to get Java 8 to work within the JMonkey IDE. However I was able to do it the other way round; add JMonkey libraries to Netbeans 8.
Install Netbeans 8
Then you follow the instructions for adding JMonkey as a library to annother IDE. The instructions are for eclipse (as JMonkey IDE is based on Netbeans it would normally make no sense to do this).
Download the most recent build of JMonkey
Unzip and save in your user directory
Open Netbeans 8
Either open an existing JMonkey project or Start a new project
Open the project properties
Select to add JARs
Browse to where you saved the JMonkey build and open the lib folder
Select all the libraries and add them
At this point it is now possible to create a JMonkey program using Java 8 code within Netbeans 8. However; the assets folder may still be missing,
If you opened an existing project it will likely be there otherwise, again, we follow similar instructions within Setting up JME3 in Eclipse but its arguably easier in netbeans. Its pretty much identical to adding the JARs so I won't include screenshots.
Open the project properties (again)
Open the libraries tab
Click add JAR/Folder
Browse to assets folder
Click open
Now you can run your project just as within the JMonkey IDE, using AssetManager to load assets. Of course you won't have all the nice JME specific features of JMonkey IDE.
Note; JMonkey is untested with Java 8, I got a basic program to run, this does not guarantee success with a more complex program (That said I have now used this technique to move my 500 class game across with zero issues; I love java)

Source code for java.lang.Object

Is there any web site that I could see the source code for the Java standard library? Most so the two classes java.lang.* and java.net.* ??
Please install Java JDK (Java Developer Kit), which is not the same as Java JRE (Java Runtime Environment).
The Java JDK contains the Java source code.
And you'd better to use an IDE (Integrated Development Environment) such as Eclipse or NetBeans to develop Java programs.
You can look for the java code via the IDE tool.
Of course. You could find it in the JDK, but also online. I also use the online version, because I find it faster as to open the folder with the JDK, brows through all the files and so on. Just google "java source object".
http://www.docjar.com/html/api/java/lang/Object.java.html
You need the JDK (JAVA SDK) installed and source of class library is at (on Windows):
C:\<Program Files>\Java\<JDK>\src.zip
Like
C:\Program Files\Java\jdk1.7.0\src.zip
Java source code is available in JDK distribution. If you have installed JDK on your machine, in JDK directory you'll find src.zip. For example, in my windows machine source code is available at: C:\Program Files\Java\jdk1.6.0_12.
Alternatively, you can find Java source code online at: Java Source Code
Thanks,
Mrityunjoy

Problem with java-doc for standard java library

I recently started using Ubuntu and installed netbeans 6.9.1. I seem to be missing some javadocs tho that get installed with the windows version.
Basically the netbeans docs are there but when the code completion comes up it only tells me the function prototype. Where theres usually a description it says that the javadocs are not found and they should be added in the platform or library manager.
Basically I just want the docs explaining the methods for basic java, swing, and awt. Anyone know what files it is i want to be getting, and can I do it all with apt-get?
OS:
Ubuntu 10
Probably you have not installed java-doc package:
sudo apt-get install sun-java6-doc
or what ever is suitable for you.
I had the same problem. Solution is very simple:
You have to download "Java SE 6 Documentation" from this page (in Additional Resources list)
http://www.oracle.com/technetwork/java/javase/downloads/index.html
It is a zip file (~50 mb). Put this file to some place you like(I suggest you to put it to the JDK directory, but you can put it to your home directory) and then open NetBeans.
Select Tools -> Java Platforms. Then select JDK on the left window. In the Javadoc tab, click Add ZIP/Folder and choose file you recently download.
When you done this, your javadoc in code completition windows will work correctly.

Categories

Resources