Configure scala project sdk for idea - java

I know there is already questions about it on stackoverflow, but none of them helped me answer my question. I just downloaded idea with the scala plugin and created a new scala project. I got the error no jdk for this project.
After looking on internet I understood that I need to give it the java sdk for it to run. readlink -f $(which java) gave me the java jdk location (/usr/lib/jvm/java-8-oracle/jre/bin/java) but adding it to the option like shown below didn't help.
How to configure the project sdk for an sbt project ?

To set the JDK, go to the Project Structure dialog in the "Project" tab. If you haven't set up a JDK yet, click "New..." and choose the home directory. Note that this needs to be a JDK (download from Oracle or install via apt), not the JVM you are using in your screenshot.

Go to Project Structure and do what I marked on the screen

Related

Can't create java application project in netbeans8.1.(ubuntu)

I am new to NetBeans and I can't create a "Java Application" project, like shown in all tutorials. I can only create a Java Free-Form Project, but this requires a build script, which I don't have either.
Do I have to download a plugin for it and if so which plugin? Or did I download the wrong NetBeans version?
I am using ubuntu version 15 and NetBeans IDE 8.1.
http://imgur.com/90AeiDG screenshot.
Just make sure you have JDK installed on your system. (I am pretty sure, it would be as Netbeans doesn't install if JDK is not found on your machine, but just to be sure about it). Also, You might have missed to select Java in Select Languages during installation.
To activate a feature manually:
Open the Tools > Plugins menu
Go to the Installed tab.
Select and activate the feature you need.
Return to the New Project dialog.
Visit this link for more help:
http://wiki.netbeans.org/FaqMissingProjectCategories
Found the plugin:
It was in the the "Ant" or the "Ant 1.9.4. Documentation 1.9.4" or Mobility plugin. I downloaded those 3 at the same time, but If I have to guess it was the Mobility plugin.
Not sure if this will help you. I've been working on Windows. I have Netbeans 8.1 and JDK 8 (version 1.8.0.73). When I first started with Netbeans and tried to create my first new Project it opened the New Project window with the Categories portion of the new Project screen focused on the Samples section. I also thought I couldn't create the type of project I wanted to create. If this is what is happening to you, see if you can scroll up in the Categories box. If you can, you should find Java at the top. If you click that, you should then be able to select Java Application in the Projects part of the window.

cannot resolve symbol javafx.application in IntelliJ Idea IDE

I tried to create a JavaFX application in IntelliJ Idea IDE but I got compile error that said:
java: package javafx.application does not exist.
I have changed the Project SDK and the Project Language Level to Java 8, reloaded the project but it didn't help. Then I checked if JavaFX plugin was enabled in the settings.
The search on Google and StackOverflow didn't give me more ideas of what is wrong.
Thank for any help in advance.
P.S. I am using IntelliJ Idea 14.0 with java8.1.0_25 on archlinux OS.
As indicated here, JavaFX is no longer included in openjdk.
So check, if you have <Java SDK root>/jre/lib/ext/jfxrt.jar on your classpath under Project Structure -> SDKs -> 1.x -> Classpath? If not, that could be why. Try adding it and see if that fixes your issue, e.g. on Ubuntu, install then openjfx package with sudo apt-get install openjfx.
This should be your perfect solution. Try and enjoy.
If some command does not work properly that means if you get any error, try to solve it yourself. I have given you the main thing you need. If your application is in a different location, or your system architecture is different, solve it yourself. It's very easy to do it. Just follow my given solution.
Step 0:
sudo apt-get install openjdk-8-jre
Step: 1
sudo apt-get install openjfx
Step 2:
sudo cp /usr/share/java/openjfx/jre/lib/ext/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib
Step 3:
sudo cp /usr/share/java/openjfx/lib/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib
Step 4:
sudo chmod 777 -R /usr/lib/jvm/java-1.8.0-openjdk-amd64
now open a new project or rebuild your project.
Good luck.
You can use the one that comes with IntelliJ: <intellij>/jre64/lib/ext/jfxrt.jar.
You need to download the java-openjfx package from the official Arch Linux repos. (Also, make sure you have the openjdk8-openjdk package). After doing that, open your project in Intellij and go to Project-Structure -> SDKs -> 1.8 -> Classpath and try removing the old JDK you had and clicking on the directory for the new JDK that will now contain jfxrt.jar.
Another way to resolve the problem :
Click the left mouse's button on the project folder in the project structure at the left, and click on "open module settings" in the list of actions
In the new windows, click on SDKs which is under the menu title "Platform settngs"
Then check on the "Classpath" list if you can find the jfxrt plugin path, if not, click on the + symbol on the right and select the repertory of the jfxrt plugin (C:\Program Files\Java\jdk1.8.0\jre\lib\ext\jfxrt.jar on my desktop)
Sample Java application:
I'm crossposting my answer from another question here since it is related
and also seems to solve the problem in the question.
Here is my example project with OpenJDK 12, JavaFX 12 and Gradle 5.4
Opens a JavaFX window with the title "Hello World!"
Able to build a working runnable distribution zip file (Windows to be tested)
Able to open and run in IntelliJ without additional configuration
Able to run from the command line
I hope somebody finds the Github project useful.
Instructions for the Scala case:
Additionally below are instructions that work with the Gradle Scala plugin, but don't seem work with Java. I'm leaving this here in case
somebody else is also using Scala, Gradle and JavaFX.
1) As mentioned in the question, the JavaFX Gradle plugin needs to be set up.
Open JavaFX has detailed documentation on this
2) Additionally you need the the JavaFX SDK for your platform unzipped somewhere.
NOTE: Be sure to scroll down to Latest releases section where JavaFX 12 is (LTS 11 is
first for some reason.)
3) Then, in IntelliJ you go to the File -> Project Structure -> Libraries, hit the ➕-button and add the lib folder from the unzipped JavaFX SDK.
For longer instructions with screenshots, check out the excellent Open JavaFX docs for IntelliJ I can't get a deep link working, so select JavaFX and IntelliJ and then Modular from IDE from the docs nav. Then scroll down to step 3. Create a library. Consider checking the other steps too if you are having trouble.
It is difficult to say if this is exactly the same situation as in the original question, but it looked similar enough that I landed here, so I'm adding my experience here to help others.
You might have a lower project language level than your JDK.
Check if:
"Projeckt structure/project/Project-> language level" is lower than your JDK.
I had the same problem with JDK 9 and the language level was per default set to 6.
I set the Project Language Level to 9 and everything worked fine after that.
You might have the same issue.
In IntelliJ Idea,
Check the following things are configured properly,
Step 1:
File -> Setting -> Plugins -> search javafx and make sure its enabled.
Step 2: Project Structure (Ctrl+Shift+Alt+s)
Platform Settings -> SDKs -> 1.8 -> Make sure Classpath should have "jre\lib\ext\jfxrt.jar"
Step 3:
Project Settings -> Project -> Project SDK - should be selected 1.8
Project Settings -> Project -> Project language level - configured as 8
Ubuntu: If not found jfxrt.jar in your SDKs then install sudo apt-get install openjfx
If you are working with IntelliJ and JDK 11
1. go to project structure ctrl + alt + shift + s.
2. add the mising
javafx libraries in the Global Libraries section.
3. add a module-info.java file with the required dependencies to your module.
module modulename {
requires javafx.fxml;
requires javafx.controls;
opens sample;
}
4. rebuild the project !
5. enjoy !
I had the same problem, in my case i resolved it by:
1) going to File-->Project Structure---->Global libraries
2) looking for jfxrt.jar included as default in the jdk1.8.0_241\lib (after installing it)
3)click on + on top left to add new global library and i specified the path of my jdk1.8.0_241 Ex :(C:\Program Files\Java\jdk1.8.0_241).
I hope this will help you
I am using apache maven with java 11 and I was able to remove all java fx problems by adding this dependency to my pom.xml file:
<!-- JAVA FX -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.1</version>
</dependency>
For me the simplest solution was to use Amazon Corretto, it is pretty much same as Oracle java.
Follow the steps:
Go to Intellij, File -> Project Structure
Go to SDK
Download SDK
From the dropdown, choose 1.8 as Java 1.8 version comes bundled with JavaFX library.
And you are good to go.
I had a similar issue, my error message was slightly different though:
java: package javafx.event does not exist
I found one solution to fix this issue. Instead of adding dependencies, modifying CLASSPATH or trying different JDK / SDK versions, you can simply select:
File -> New Project -> JavaFX -> Location of the code
After restarting, the build is successful.

Importing Git Repositories into Linux Eclipse (3.8) and Running/Compiling Them as Java Projects

I am using Eclipse 3.8 for Linux with EGit and am trying to import my Java Git repos from Github. The problem is, they are not recognized as Java projects, and therefore Eclipse does not compile them.
How can I get Eclipse to recognize them as Java projects? Thank you for your answers.
go through this way:
eclipse>right click on project>build path>configure.
here you will see a tab called library,
library>"add library">"jre system library"
you will see as option which jre you want to add. you select execution environment as what ever jre u have installed. thats it.
The problem was that I imported it as a general project. For anyone who gets this problem like I did, never import as a general project on Linux (do it on Windows). Instead, choose to use the project creation wizard. Set the name and everything should go by smoothly.

IntelliJ IDEA can't setup JDK

I'm trying to setup JDK in IntelliJ IDEA and whatever I do, or whatever JDK version I select, nothing happens. The following situation remains:
So I told IDEA what JDK it should use, but it still asks me to setup a JDK. Is this a bug or am I missing something? Can I apply any workaround to make everything work as usual?
ADDITION
The steps which I go through setting up the JDK:
situation before setting up:
the first step:
the second step:
the third step:
the situation after setting up JDK:
SDKs:
module settings:
File | Invalidate Caches is the first thing you should try in case of such issues.
Select your modul in the "Project View" and press F4 in the "Project Setting"select "Module".
In the "Module Settings" overview you can add/remove the Modul SDK.
Following this worked for me :
Select your module in Project View
Press F4
Go to SDK
Select you SDK
Make sure you have various jars in there. Else, select proper directory.
In my case, even though correct directory was selected classpath,sourcepath etc were empty.
So I had to select jdk installation directory one more time, which loaded all the jars and solved the problem.
In my case just File | Invalidate Caches and Restart did not work. Upon Right clicking the project and going to Module Settings , I had no SDK selected under Project Settings->Project.
I followed below steps
Press F4
Select Modules in Project Settings
Set up Module SDK from the drop down or add the new one.
Apply & OK
For someone like me, looking for a way to setup an offline documentation in IDEA on UBUNTU Linux. You should install the openjdk-8-doc (or openjdk-X-doc in general case) package, then go to File|Project Structure|SDKs|1.8(still 1.X in general), then select tab Documentation Paths and add the path /usr/lib/jvm/java-1.8.0-openjdk-amd64/docs/api there.
Note, that path of Java docs installation may differ on your machine. You are able to check the path of Java docs installation executing dpkg-query -L openjdk-8-doc | less in a shell.
I was seeing this exception in the console:
NoClassDefFoundError: com/intellij/remote/RemoteSdkConnectionAcceptor
which was caused by the python community edition plugin on Intellij IDEA 2016.2.5.
After updateing/disableing the plugin, I was able to setup the SDK again.

Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files

I'm a Java noob (but have been programming for 25+ years, and have worked with OO languages from day 1).
All of a sudden I started getting this error:
Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files.
Not sure what caused this condition, and not sure what Java's asking me to do. I'm working in the NetBeans IDE. The last thing I attempted to do is add some binary (image) resources to my project.
In my case the JDK setup in Netbeans was fine. It was just one of those strange Netbeans issues that come out of nowhere.
My fix was:
Clear the Netbeans Cache i.e. delete the folder:
C:\Users\\AppData\Local\NetBeans\Cache\
It means you haven't told netbeans where your Java 1.6 installation is. Go into settings, add the JDK (JDK->Add->New), and select the directory above 'bin' for your JDK16.
This error can occur at two scenarios:
Right click your netbean project -> Properties -> Libraries
After select Libraries , right panel on top you can see "Java Platform" combo box. This Jave Platform is missing for your project. You need to add using Manage Platforms bottom beside Jave Platform combo box.
Even thought scenario (1) is correct it can happen. Because your project has reference to another netbean project in your Libraries. This reference project is missing Jave Platform.
I have Linux in my office and Mac in Home and this problem is frequently when I share projects in github, I solve it removing the build directory and doing clean and build.
Right click on project - Properties - Libraries - Select the correct jdk version from the Java Platform combobox.
NetBeans bug
If your project depends on other projects, open and clean build all of them(that fixed it for me).
Most likely cache-related stuff. Clean up NB cache as suggested by someone before
You should remove the files under private folder in the nbproperties folders.
for me any recommended way early didn't helped, but changing in project Properties -> Source/Binary format to JDK 7, Save than change back to JDK 8 fixed this error

Categories