I am getting the below error when executing gradle.bat. I have checked the URL path and it looks fine. The URL is defined like this in the wrapper properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
Here's the error message:
Downloading https://services.gradle.org/distributions/gradle-2.1-bin.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
Could someone help me on this?
Go to "C:\Users\[yourusername]\.gradle\" folder (hidden folder - Go to folder option and enable show hidden files if folder is not showing up)
Look for file "gradle.properties" if DOES NOT (most likely this would be the case) exists, Create it under "C:\Users\[yourusername]\.gradle\
Copy and paste following code (More detail ... https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties ... look for "20.3 Accessing the web via proxy" for https and user/pwd variables)
systemProp.http.proxyHost=[PROXY SERVER]
systemProp.http.proxyPort=[PROXY PORT]
save and try again
look for gradle.properties file open it and change from 'distributionUrl=https\' to 'distributionUrl=http\' that will fix it.
I was facing the same problem when I was connected to WiFi with a download speed of 80 Mbps which is good enough, I guess. After spending hours while still being clueless, I just changed the network. Connected to hotspot from my mobile data with a much lower download speed of around 4 Mbps. The error vanished! Maybe something was wrong with the WiFi.
1) Go to your project directory
2) Find below file on your project directory:
gradlew
gradlew.bat
3) Edit gradlew file and change DEFAULT_JVM_OPTS variable value as below:
DEFAULT_JVM_OPTS="-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX"
save it.
4) Edit gradlew.bat file and change DEFAULT_JVM_OPTS variable value as below:
set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX
save it.
5) Now run your "gradlew clean build" and check.
Please set your appropriate value on the place of XXXX
Note: gradlew is use for linux system user and gradlew.bat is user for window system user
Make sure you have enough bandwidth for the download.
I had the same problem just 15 minutes ago (that's why I'm on this page in the first place). Same error message --- and then I noticed that my uTorrent client was occupying the whole datalink. So I killed it, and run gradlew.bat again. This time everything went just fine...
I had similar issue, fixed by following steps:
Created: C:\Users\<username>\.gradle\gradle.properties
Values entered in the property file as below:
systemProp.https.proxyHost="company proxy server"
systemProp.https.proxyPort="company proxy port "
systemProp.https.proxyUser="user login "
systemProp.https.proxyPassword="password "
systemProp.https.nonProxyHosts=localhost
You can try HTTP instead of HTTPS.
I had this problem for a flutter project and what I did was create a new flutter project with the same name as my problem flutter project. I then copied the files from the "android" directory from the new project into the existing flutter project. Basically some set up file was messed up. I don't know which one, but this did the trick
Maybe it's a bit late but you might have to try to UPDATE your ANDROID STUDIO. Had a similar problem, working on Linux pop_os (Ubuntu derivative). So I had Android SDK on my $PATH and everything set well but Ionic v3 build was having a Gradle issues while trying to download.
I simply updated my Android Studio and tried again and it worked. Good luck
Go to your command prompt and set the HTTP and HTTPS proxy
Execute the below in your cmd -
set HTTP_PROXY=http://<proxyservername>:<port>
set HTTPS_PROXY=http://<proxyservername>:<port>?
Once you have set your proxy variables , try rebuilding or re-assembling your application / project
I've got an issue with Android studio. The value of the distributionUrl field in the graddle-wrapper.properties has been changed during package name refactoring.
If error is under flutter
Just hoping this might help someone in the future...
When i encountered that error in flutter, I just had to change network from the current one which seemed unstable, am sure build.gradle was trying to get more resources from internet.
try disconnecting and reconnecting to the network
try changing networks(wifi- date or data - wifi)
In my case disconnecting from my office VPN fixed the problem
Just remove your .android and .gradle folder from C:\Users\[Your user name]\
Uninstall android studio and reinstall it
Open any simple android studio project and run it. It will automatically set up the Gradle and other things
Close the project and run your flutter project. It works for me!!!
I got a project and imported it in Eclipse (it is an android project).
The project works on other computers, but unfortunately not on mine.
The error which comes up is in the console of eclipse when i import the project:
"Unable to resolve target 'android-8'"
Furthermore do i get multiple errors in on of the .java-files in the src folder of the project.
3 of them are showing "String cannot be resolved to type":
Here the code (It is for a music player the timer /showing of the seconds):
/**
* Function to convert milliseconds time to
* Timer Format
* Hours:Minutes:Seconds
* */
public String milliSecondsToTimer(long milliseconds){
String finalTimerString = "";
String secondsString = "";
I hope you can help me!
Thank you so much in advance!
If you have any questions please let me know.
Thanks guys.
Cheers
You'll be having project.properties file open that and change the android-8 to whatever android version you have. After changing this goto Window->Preferences->Android. You'll be having target name & api level. select any one of them & specify it in project.properties file.
It seems you have something set with a build target of API 8. Perhaps a subproject or library?
If that's intended then it sounds like you need to download Android 2.2 (API 8) through your Android SDK manager.
Right click on the project, Properties -> Android -> Select the build target -> Apply -> OK
I'm trying to Use android with Netbeans , but every time i try to do it , it gave me warning message Like this:
Exactly what i do :
Tools -> Plugins ->Settings tab ->press Add button and fill name "NBAndroid" and URL "http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml"
then i get the above warning Message
It's my first time to try it , and googled it but didn't find any thing ,So i need the help for do that , thank you
Finally , I found the solution :
According to Installation using AutoUpdate center
address of our update center that is:
http://nbandroid.org/release72/updates/updates.xml if you run NetBeans 7.2 or newer Previous update center at
http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml
is removed now as it caused confusion about current version and what
is supported and what not.///////////and this is was my problem , so
i used the first one , and it's ok now
I'm a beginner in Java and am trying to run my code using IntelliJ that I just installed as my IDE with JDK 1.7. The following piece of code keeps does not even compile and keeps giving me the error:
Error: Could not find or load main class libTest
Code
import java.lang.Integer;
import java.lang.String;
import java.lang.System;
import java.util.*;
class book {
private String name = "trial";
private int bookCode=1;
private int issued=0;
public void Issue(){
if(issued==0) {
issued=1;
System.out.println("You have succesfully issued the book");
}
else {
System.out.println("The book is already issued. Please contact the librarian for further details");
}
}
public int checkCode() {
return bookCode;
}
String readName() {
return name;
}
public void setName(String newName){
name=newName;
}
public void setBookCode(int newCode){
bookCode=newCode;
}
}
class library {
private ArrayList books=new ArrayList();
public void getList(){
for(int bk:books){
String bName=books(bk).readName();
System.out.println((bk+1)+") "+bName);
}
}
}
public class libTest{
public static void main(String[] args){
library newLib= new library();
System.out.println("code working");
}
}
Is there any change that i have to make in the compiler settings?? Or is it the code.
This might help:
1) "Build" menu -> "Rebuild Project".
Sometimes Intellij doesn't rewrite the classes because they already exist, this way you ask Intellij to rewrite everything.
2) "Run" menu -> "Edit configuration" -> delete the profile -> add back the profile ("Application" if it's a Java application), choose your main class from the "Main Class" dropdown menu.
3)"Build" menu -> "Rebuild Project".
If none of the above answers worked for you, just close your IntelliJ IDE and remove the IntelliJ IDE file and folder from the root of your project:
rm -rf .idea *.iml
Then open the project with IntelliJ. It must work now.
For me the solution was to fix the output directory under project settings. Before I was using just "target" for the Project compiler output. Instead I updated it to have a full path e.g. D:\dev\sigplusjava2_68\target
I had this problem and I tried everything under the sun that I could think of and on this site.
None of my Java classes were being picked up after I pulled from a remote branch. All the classes had red Js by their names in the Project Hierarchy, not blue Cs.
In the end, I tried to follow this tutorial and a few steps in tried something not described and fixed the issue:
https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
Here's what I did:
Goto File | Project Structure, or press Crtl+Shift+Alt+S
Select Modules under the Project Settings section.
In the Sources tab click Sources on the 'Mark as:' line.
Click the Apply button.
For some reason, all my classes then had blue C's.
Someone with a better understanding of how IntelliJ and/or IDE's might be able to explain the phenomenon, but all I know is now it can see all the classes and more importantly the main one, and run.
Invalidate cache and restart your IntelliJ, it worked for me.
Explicitly creating an out folder and then setting the output path to C:\Users\USERNAME\IdeaProjects\PROJECTNAME\out
seemed to work for me when just out, and expecting IntelliJ to make the folder wouldn't.
Also try having IntelliJ make you a new run configuration:
Find the previous one by clicking
then remove it
and hit okay.
Now, (IMPORTANT STEP) open the class containing your main method. This is probably easiest done by clicking on the class name in the left-hand side Project Pane.
Give 'er a Alt + Shift + F10 and you should get a
Now hit Enter!!
Tadah??
(Did it work?)
File > Project Structure > Modules > Mark "src" folder as sources.
This should fix the problem. Also check latest language is selected so that you don't have to change code or do any config changes.
I know this was asked a while ago, but I was just stumbling over this issue and thought my findings might help others. As pointed out, the error message is basically a result of the out folder. That's because, when you're trying to run the program, it compiles the code first, and puts the compiled result to the out location, and then it tries to load the compiled code from the out location. If the compiled code is not in the location expected, you'll get the error.
The point I'm particularly wanting to share is that some times, the code is not compiled (built), even though your run configuration specifies "Build" in the "Before launch" section of the configuration panel.
When can this happen?
One situation that can cause this to happen is if you're using modules and you manually delete the module out directory. For example, if I have a module named "foo", there should be a directory named foo under out/production. If you manually delete it, the build system may not know that it needs to be rebuilt.
Even worse, if you select Build | Build module 'foo', it still may not rebuild the module. If that's the case, you should select a file in the module, for example 'bar.java' and then select Build | Recompile 'bar.java'. Now the out directory out/production/foo should be restored.
Since IntelliJ typically knows about any changes going on, this surprised me, and took me a little time to figure out, so I thought I'd share.
Check your class module : I have encountered this problem with intellij :
I have a maven multi-module project, the problem is that i runing a class which not exist the module within the configuration, so my problem is fixed by setting the right module ("edit configuration" -> "use class of module")
may this help you
I had to mark the "src" folder as "Sources". After restarting IntelliJ and rebuilding the project I could run the project without further issues (see screenshot).
Edit: You can access the "Project Structure" tab via File->Project Structure or by pressing Ctrl+Shift+Alt+S.
I ran into this problem when my Java class was under src/main/kotlin. After I moved it to src/main/java, the problem was gone.
I have faced such problems when the class is in the default folder, i.e. when the class does not declare a package.
So I guess using a package statement (eg. package org.me.mypackage;) on top of the class should fix it.
Open Modules Tab (Press Ctrl+Shift+Alt+S). I had two modules under one project. I've solved the problem after removing the second redundant module (see screenshot).
After creating your project in intelliJ, try running the following command:
mvn package
I have tried all the hacks suggested here - to no avail. At the end I have simply created a new Maven application and manually copied into it - one by one - the pom.xml and the java files and resources. It all works now. I am new to IntelliJ and totally unimpressed but how easy it is to get it into an unstable state.
Invalidating cache didn't work.
I edited the main class java file with a dummy change and ran it. It worked.
In my case the problem seemed to be related to upgrading IntelliJ. When I did this I overwrote the files from the old IntelliJ with the files from the new IntelliJ (2017 community to 2018 community). After that all of my projects were broken. I tried everything in this thread and none of them worked. I tried upgrading gradle to the latest version (4 to 4.8) and that didn't work. The only thing that worked for me was deleting the entire IntelliJ folder and reinstalling it. All of my projects worked after that.
I have tried almost everything suggested in the answers here, but nothing worked for me.
After an hour of just trying to run my application, I noticed that my project's path included non-ASCII characters (Arabic characters). After I moved my project to a path with no non-ASCII characters, it executed just fine.
Goto File-> Invalidate Caches and Restart .
Else delete rm -rf .idea *.iml
and restart InteliJ
You can run the maven command on the pom.xml file in your project directory:
mvn clean install
For me - i tried few of the options above, did not work. Then i just renamed my Application class and that probably forced intelliJ to build a fresh jar and error message started to change. Then i renamed it back and it worked.
Mark the directory as a source directory. Opened via Ctrl+Shift+Alt+S
modules.xml with wrong content, I don't know what's matter with my IDEA.
I inherited a bunch of .JAVA files from elsewhere and couldn't figure out how to get them to work in any IDE. Ultimately I had to go to the command line where the Main.JAVA file was and run javac Main.java. This created a bunch of .CLASS files. The IDE's were then able to figure out what to do.
I got this error when using Scala/SBT. IntelliJ could not find the main class, even though everything was set up correctly.
My solution: delete the <user>/.sbt/<version>/plugins/target folder, then restart IntelliJ.
You probably would have specified a wrong package and the package hierarchy would not be right. Look below
The ide would highlight the wrong path in that case.
I'm using IntelliJ with Spring and my main class is wrapped in a JAR.
I had to mark the 'Include dependencies with "Provided" scope' in the Run/Debug configuration dialog
We are at File/Project Structure..
Answer might be:
Folder indicated as "content root" needs a child folder where the code is.
Plus find the button that marks code as excluded and not.
Not to be confused with tickbox that states excluded without telling in what phase and what**
Is it compiler exclude or runtime exclude? You are doomed to test and lot.
So no that tickbox but icons and colors.
As an idea we need to crack how it was originally thought to work. They never got it to work in first place and started add things in premature codaculation style.
It has been so many years and you cannot expect any improvement.
But as cure we can hack out some way to get it right every time.
Another thing you can check here is the actual command that is being passed to the JVM and make sure it looks OK. Scroll to the top of your Run console, it should be the first line.
Spaces in your Run Configuration VM Options field will malform the app startup command and can result in this error message
-DsomeArgument="arg with space must be quoted"
I am working with Kotlin but am guessing the problem is the same. I would start a project, create a single file and add main to it and the IDE couldn't find the main.
I tried the things in this list and none worked. I finally mentioned my frustration on one of the IntelliJ pages and was contacted. Of course, it worked fine for IntelliJ. After a couple of days back and forth, I noticed that the highlight function wasn't working and mentioned that. It turned out something was wrong with the IDE settings. I still don't know specifically what was wrong but the fix in my case was to reset the IDE settings. File->Manage IDE Settings->Restore Default settings.
After this, the green triangle start icon became visible to the left of my main function and things continued to work normally for subsequent projects.
Thanks to Konstantin at JetBrain's support for his patience.