IntelliJ Generated Ant build results in broken code - java

I added JDK and Ant to Enviroment System variables but that doesn't stop a simple Ant build in IntelliJ from breaking. I have set the system path variable to accept both Ant's directory and the JDK enviroment. I have created JAVA_HOME and Java is still functioning in the cmd.
There isn't any code in the project. There is just this build that generates this default code.
I haven't altered anything once I started the build and if I go into Project Structure -> Project Settings, I have the Project SDK set to 1.8.
What is going on here?
**EDIT: I managed to remove a lot of the errors by toggling a box to Generate the Ant Build to Use current IDEA instane for idea.home property. **

It looks like many properties from test3.xml are not available/defined in module_test3.xml. Did you already try to do a "Generate single-file ant build" (the second radio button in the "Generate Ant Build" dialog)? This could be a way to avoid the problem of Ant properties from one build file not being available in another build file.
Are you very attached to Ant for building your projects? You could give Gradle and/or Maven a try, to see if these tools work better for you.
If you are doing Android development, you could also check out Android Studio. If you are using IntelliJ IDEA, I would definitively consider upgrading to version 15; the community edition is free and version 10.5 is around four years old now.

Related

IntelliJ IDEA is not recognizing my java files as runnable and instead wants to run the class files. Any ideas of how to fix?

Anytime I try to run a java file by clicking run, it instead tries to run the class file and thus gives a no main method error.
When I try to right click on a java file and run that, it doesn't recogize it as a file that is runable.
I am still able to run programs from the command prompt but I would prefer to be able to run them in IntelliJ.
This occurred after trying to create a Class path when using JSon Libraries.
Edit:
Normally it shows java files with this icon:
But instead it's showing this icon for java files:
I think the change in icon might have something to do with it.
Edit 2:
the exact error I get is "C:\Program Files (x86)\Java\jdk1.8.0_181\bin\java.exe"...bunch of other program file locations
Error: Could not find or load main class sample.Main
Process finished with exit code 1
I had the same problem and found out that my src wasn't marked as Sources Root. To change this:
right-mouse click on your src
navigate to "Mark Directory As"
choose "Sources Root"
It will now recognize your files correctly and your main classes will be able to run again
IntelliJ not recognizing my .java-files
Problem solved
I had a similar problem.It wouldn't pick up ModlServer in any project. (Not just limited to the one I had open).
I had to file -> Manage IDE Settings -> Restore Default Settings
Note: I lost all my live templates, fonts, etc so just a heads up.
I restarted my computer and that somehow fixed it.
My issue was that I have multiple modules for my project and the module I was working on (where java files were not recognized) was not included in the main pom. I just added that module in the main (project) pom and it worked.
Right click on the project and click 'Add framework support' all directories and classes should now be the right type.
I've fixed this at Intelij2023 by using JDK17 as the JDK the IDE uses to import java source files.
Mind this JDK version does not need to be the same you use to build your project.
Go to: Settings > Build, Executio, Deployment> Build Tools > Maven > Importer
Set the JDK For Importer to zulu-17
I'm using zulu-17 as JDK for imports and coretto-8 to build the project (having JDK version 8 seems to be preventing intelij to properly recognize the project structure)
If you are using Maven or Gradle, try to re-import the project and see if that helps. Could be that your IDEA project has some incorrect settings in it set by mistake, so this way those would be removed.

Java project from existing ant build file doesn't appear as in version control

I have a repository in which I have a simple ant project (only the src directory and the build.xml file). I did a checkout of this project in a local copy. Then I opened Eclipse, created a "Java Project from existing Ant build file" and it worked fine. I can build, clean, run, generate javadocs, etc. However, my problem is that the source files in the packages, as well as the project itself, doesn't appear to be under version control in Eclipse. I can work with it fine from Cygwin, but not from the GUI.
The odd thing is that I have several regular Java projects, on the same repository which are synced fine by Eclipse, so it's not a version issue.
When I created the projects that work, I had to go to Team->Share Project... and Eclipse told me that they were already under version control and updated its configuration. However, in this current case, this isn't working. Any suggestion please?
EDIT:
I'm using svn 1.8.
UPDATE: I tried creating a regular Java project, and this time the version control looks fine, so it appears it's an issue related only to Java Project from Existing Ant build file.
The problem is that Eclipse doesn't know your project is using Subversion as a version control tool. You did a checkout outside of Eclipse, then you set up Eclipse as if this was a non-version controlled project.
To get Eclipse to recognize the project as under Subversion, you need to let Eclipse know. This means you should have said "File->New->Project, and select SVN->Checkout Project from SVN in the new project wizard. Then, Eclipse would have checked the project out in Subversion for you, and Eclipse would understand this project is in Subversion.
Unfortunately, I am not quite familiar enough with Eclipse to know how to tell Eclipse that the current project is really under version control. The best I could come up with was:
Right-click on the project and select Team->Share
Say this is a Subversion project you want to share.
Select the Repository to use
Select the folder where you want this project, and select the current folder.
You get the following warning:
Warning: The specified folder already exists in the repository. If you continue, that folder will be checked out to the existing location. Do you want to continue?
Your project will now be "checked out" over your current project. Everything should be okay because the files you have either match what is in Subversion or are modified versions of what is in Subversion.
You will be then asked to use the Synchronized view. Check "Yes", and then switch back to the Java view. Eclipse will now know your project is under Subversion and everything should work fine.
Note the use of Shoulds and Coulds. This is my way of saying that the advise given is done on an "as is" basis and I am not responsible for any damage done by following this advice, so please don't sue me.
It's basically your standard open source license.

How to upgrade the ant built into eclipse?

I use ANT for all my builds and I also use eclipse as my IDE and I would like to be able to use the latest version of ANT in my eclipse, frequently the ANT that ships with eclipse is a point release behind. so my questions are.
Is there an easy way to get the eclipse ant plug-in to use the latest version of ANT?
Is there any easy way to add extra custom ant libraries to the built in eclipse ANT plug in, as I would like to be able to add things like the subversion task to my ant build and have it accessible from within eclipse.
Download and unpack the latest ant build anywhere on your hard disk, then run Eclipse, and go to
Window > Preferences > Ant > Runtime
and click on the button called
Ant Home
Browse to the ant folder that you just unpacked, and choose that folder. Now Eclipse will use this version of ant instead of the built-in ant. I use this way, and actually prefer it, because now I have the same ant version in command line and in Eclipse
In the same window you can add any other jars with 3rd party ant tasks, and they will be used by ant (just 'add jars'/'add external jars')
While not easy, by my standards at least, this is the way to update the ant plugin. At least for RAD 8.5, I'm sure eclipse is similar.
Go to Help -> About RAD -> Intallation details -> Plugins ... locate the org.apache.ant plugin version you are using. Note the Provider ... in this case for me it was Eclipse Orbit.
Next you need the repository URL for Orbit, googling got me this page.
http://wiki.eclipse.org/Orbit/FAQ
Which describes how to locate the repository.
Find the Orbit build drop that you need here:
http://download.eclipse.org/tools/orbit/downloads/
Add 'repository' to the URL of the drop. For example, for the drop in
http://download.eclipse.org/tools/orbit/downloads/drops/S20101204061544/
the URL that you would use is:
http://download.eclipse.org/tools/orbit/downloads/drops/S20101204061544/repository/
I personally went with
http://download.eclipse.org/tools/orbit/downloads/drops/R20130827064939/repository
Next, if you are behind a proxy, make sure that your proxy config is correct and the IDE can connect to the internet.
Then go to Help -> Install New Software
Next to the Work With dropdown hit the Add button and enter the repository information.
Select the apache bundle from the list and complete the steps of the wizard to perform the update.
Now that the repository is added to the list, for future updates you can use the Help -> Check for Updates menu item.
Good Luck, took me a day to figure that out and work through it.

Google Eclipse plugin recompile problem

I have installed Eclipse Helios(3.6) and Google plugin to develope app in GAE/J.Then created project and runned it sucessufull. Later made some changes in source code but it doesnt recompiled. Previous compiled version is in use. It doesnt compile until I make changes in appengine-web.xml. Could you suggest how to solve the problem please?
PS : I had the same problem in Eclipse 3.5. Also I added javac to SYSTEMPATH.
You could try the following:
the folder where your java files are in is a "source folder" (check it via project properties, "build path")
turn on "build automatically"? Can be found in Menu "Project"
Maybe refreshing your workspace automatically will help (Window->Preferences, and search for workspace)
The Project is automatically not builded or recompiled, when there are problems marked by eclipse. Take a look into the marker panel of eclipse and solve the problems.

Android Eclipse Classpath - want to add classpath container path but eclipse won't let me

I'm using Eclipse to learn to develop Android applications in Java. I haven't used Eclipse before.
The project I'm trying to use (supplied by OReilly as part of 'Android Application Development') is MJAndroid. When attempting to run the project, the Run fails, and the Problems tab mentions com.java.Object can't be found, and Eclipse asks me to check the build path. Clicking
Properties -> Java Build Path -> Libraries, the message 'Unable to get system library for the project' is displayed.
On a working project, Properties -> Java Build Path -> Libraries has an entry for Android 1.1, which if I click Edit, has the classpath container path of com.android.ide.eclipse.adt.ANDROID_FRAMEWORK.
It seems a simple matter of adding the correct container path to my non-working project. However Eclipse seems determined to make this as difficult as possible. No matter what I chose to add - jars, externals jars, variables, libraries, class folders, external class folders, nothing seems to take the form of 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK' that the 'Android 1.1' entry on the working app has.
How can I add this namespace to my project so it resembles the working one?
I'm quite sure it's a problem with Eclipse's somewhat odd user interface. Frankly there' nothing I'd prefer more than a file to modify and set such information - my background is in Python, and the whole eclipse environment seems an unnecessary burden.
I had faced the same issue when I imported a sample code downloaded from the internet. I am using android sdk 1.5 with 0.9 ADT plugins. Here is a simpler way to fix the andoid library reference issues
Right click on the project which has
issues and select properties
Select the appropriate Android build
(1.1, 1.5 or 1.5 with google api) and
say ok
Again right click on the project and
select "Android Tools > Fix Project
Properties"
Fix the imports once (if required)
Refresh the project and you should be
ready to go without any manual
editing
I faced this same problem after importing a project through GIT. The problem was that I didn't have the same target android platform installed, and the build path somehow got corrupted.
The first obvious thing i did was changing the target sdk in the project.properties, but even after cleaning up the project and Android Tools > Fix Project Properties, it didn't help and I was still getting the build error.
My solution after wasting close to 1 hour trying to figure this out?
RESTART ECLIPSE
Everything worked fine after that. Eclipse is pretty fickle. Only through years of experience you'll then understand her well. :)
Had the same problem and it turns out the Android SDK Location was not set which was a really simple fix. Go to Window->Preferences, click on 'Android' on the left hand menu, fill in the location of the Android SDK (e.g. C:\Program Files\Android\android-sdk) and click OK. Everything worked fine for me after that.
Found the answer in this set up guide: http://developer.motorola.com/docstools/library/Installing-Android-Dev-Environment/
Sometimes Eclipse can get a bit funny (technical term) with classpath container resolution.
You have a working project in your workspace, so you can rule out plugin installation issues. You could try opening the .classpath file (hidden by default, select the triangle in the top-right of the Package Explorer view, select Filters... and uncheck .* resources) and manually adding the container declaration.
`<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>`
You may then have to close the project and open it again (right-click->Close Project) before Eclipse recognises the change.
You may also find that there is an Android builder and/or nature. If you compare the .project files for the working and non-working versions you may see entries for Android builders/natures. Copying the relevant entries may resolve the issue.
sometimes, eclipse can help you.
In Android projects, click right button on the project-> Android Tools -> Fix Project Properties.
It's usefull in class path errors!!
Luck!
I would verify you have the correct version of Java installed as well as the Android SDK. I would recommend installing/reinstalling the ADT plugin in your eclipse, makes it alot easier to create the android project.
http://developer.android.com/sdk/1.5_r2/installing.html
Also. I guess the path of the Android SDK must be setup correctly. This happened when I was overloaded with projects and I decided to create a new workspace copying some existing stuff into it.
Seems that the new workspace requires you to setup these details too once again
Is that setup properly?

Categories

Resources