Trouble with importing MathParser external library in IntelliJ - java

as above, I cannot get access to classes of external library MathParser imported with Maven in IntelliJ. I've configured pom.xml file and enabled auto-download, so (as seen on the bottom of Project files section) it got downloaded, but when I try to use classes/import with import org.mariuszgromada.math.mxparser.*; - auto and manual import do not work.
Here's a screenshot of current situation
Any ideas?
Created new project for this test purposes, but same thing is happening. In ,,External Libraries" (in project files on the left in the screenshot) the lib appears , nevertheless no way to access to it's classes.
Update:
1) I've deleted jdk, and downloaded the newest 10'th - no results.
2) Reinstalled IntelliJ IDE couple times, same. Also I've tried to set up IntelliJ on Windows in VirtualBox (I need to finish my short project), same with jdk 10, and finally it worked. Nevertheless, I need to make it work without externalising from macOS (also, friend of mine with Mac, didn't have any similar problems). Totally same procedure, but on the macOS side on my Macbook I cannot import anything from this exterbal library (what is possible on virtualised Windows side).
3) I was trying to clean my Mac out of IntelliJ folders, then uninstall it, then imported settings from ,,healthy mac's IntelliJ" - still nothing new.
Solution:
I've reinstalled macOS, and finally that's how I've solved the problem.

Everything seems to be correct. You can try to
directly import of mxParser by changing import to import org.mariuszgromada.math.mxparser.mxParser or
check which classes you have in that package by pressing Ctrl + Space after mXparser package in import statement.

Related

Eclipse clean has removed most of my import statements

I was getting "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files" errors in all of my projects after a reboot (I run Eclipse on Windows 7). Everything was working fine before the reboot. So I tried cleaning all projects and restarting Eclipse - a few times. That didn't work so I followed some advice here and shifted
rt.jar up the list in my Windows -> Preferences -> Java -> Installed JREs. That seemed to fix the problem for all of the appcompat_v7* projects, but....
Now I find that Eclipse has rather helpfully removed most of the import statements from all of my classes. This leaves me with about 1,000 compilation errors to deal with. Is there a quick way of re-instating the required import statements, or do I really have to go to each class, each error and manually re-instate each import??
Right-click button on the project and select Source>Organize Imports.
That should work... if you have the libraries set up correctly.

eclipse can't import java.util?

I recently installed Eclipse 4.3 (Build id: 20130919-0819) onto my Windows 7 x64 machine and imported my old workspace, but all of them had some kind of strange problem (they had red exclamation marks on the project names instead of error x's). So I re-imported one, which got rid of the exclamation mark, but there is exactly one .java source file with errors now.
It says it can't resolve "Import java.util", and of course everything using that also has an error too.
What the heck? Isn't java.util one of the base libraries? Also, I can't seem to find where to download/install packages. Does eclipse have a separate program for that? I seem to remember using a package manager to install a few packages or SDKs or something back when I got eclipse on my Windows XP machine.
BTW yes I selected the x64 windows version, not the x86 one. And if it matters at all, when I tried to unzip it with 7zip, it gave me many errors and wouldn't work, so I tried unzipping with the default windows zip thing and that seemed to work just fine.
import must be spelt with a lower-case "i". Try this!
...additionally, you might be wanting to say "import java.util.*;" because util is a package that contains many objects. The * tells it to import all of those objects!
java.util is the collections framework package name. you need to specify what classes you want to import so you can refer to them using there unqualified names, makes code more readable.
if you want to import all classes in the package use import java.util.*;
if you need to add third party packages to your project, you can use a dependency management tool like maven and this can be easily integrated with eclipse.

Using Java.applet.Applet in Eclipse

I am little .NET oriented, and new to Java stuff. Using Eclipse IDE, whenever i extend my class by Applet as:
class xyz extends Applet{ . . . };
this gives error. and no suitable oauto-fix. i tried importing manually as
import java.applet.Applet;
But this gives error too. I tried to look up for the problem over internet, but only find the way to create applet, not the solution. Kindly guide me. Do I have to import some files in my Eclipse IDE?
(i forgot to mention, I am using it in my Android Application Project)
As Mr. Thompson said, applets don't work in android. The tutorial you posted may does some Android stuff later - however not in that specific tutorial you linked ("But wait until we start developing on Android" [...at some day in the future and in some other tutorial]). And as you may see the first screenshot he selects
"Package Explorer >> New >> Java Project" and not the below Android Application Project.
So did you really (exactly) followed that tutorial step by step? If so, everything should be working. If not you made a mistake or your eclipse is misconfigured.
whenever you import any class using import statement, it will import from JRE which is linked to Eclipse IDE.
If your IDE not linked to JRE then you will get this type of errors.
to remove these errors, first set some settings in Eclipse.
go to window >> Preferences - you can see one screen now.
here you can go to java >> Installed JREs
if there are no JRE then you can add JRE from your local C: drive.
generally you can find your JRE on the location below(if you have windows machine):
C:\Program Files\Java\jre7 (if you have 32 bit OS)
OR
C:\Program Files (x86)\Java\jre7 (if you have 64 bit OS)
you can also set the compiler compliance level same as your JRE version or below to JRE version but not upper version .(for this you can go to java >> compiler)
In your project in Eclipse, check if you have JRE System Library, like this
(source: ibm.com)
If not, Go to Window - Preferences - Java - Installed JREs page to specify the path of your JRE or JDK.

The import org.apache.cordova cannot be resolved

For some reason, after going through Phonegap's non-inclusive instructions (it doesn't even mention setting up ANT, or the headaches with Ant and JDK), this doesn't work at all:
package com.HealthTrustSoftware.AndroidTemplate3;
import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;
public class AndroidTemplate3 extends DroidGap
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
It gives 5 errors referencing the fact that org.apache.cordova can't be resolved. I'm entirely sure what to do at this point. Please help. This is after 3 hours of trying to get the sdk working and finally being able to open a project within eclipse. After following the steps on their documentation, I am left with a wasted 3 hours unless I can figure this out.
I just ran into the same problem. Following what was written in here, I finally made it work.
After you download cordova from phonegap github page, you will find cordova-2.2.0.jar and cordova-2.2.0.js in lib/android folder. After running "./create ...", copy cordova-2.2.0.jar into your projects libs folder and cordova-2.2.0.js into your www folder. Then import the project into eclipse and it should work.
I had to go to "Project -> Properties -> Android" and select a newer SDK (I selected the latest one available on the list) and than run the "Project -> Clean" as well.
In addition to copying cordova-2.2.0.jar from the phonegapp download to the libs folder of the project I had to manually add it to the projects libraries.
Procedure: Project -> properties -> Java Build Path -> Libraries -> Add JARs... Then select the libs from the project itself
Android studio: File -> Invalidate cache / Restart. Worked for me...
I initially got around this using one of the solutions posted above: about downloading the phonegap from github and pasting in the cordova-2.2.0.jar and cordova-2.2.0.js files into the generated directories.
After fiddling around with the path and environment variables these files are already in place (project/libs/cordova-2.2.0.jar and project/assets/www/cordova-2.2.0.js) now for me after running the "create" command on command line.
I am using the ANT that came bundled with Eclipse so my PATH variable includes:
C:\Program Files\Eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\bin;
and I added an environment variable for ANT_HOME of:
C:\Program Files\Eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730
I tested adding \bin or removing it to both the PATH and environment variable for ANT_HOME and this was the winning combination.
Run cordova -d build. If it says anything about "Unable to locate tools.jar", fix that. Then completely rebuild the application by running cordova platform rm android. Also remove the project from eclispe. Then recreate the app by running cordova platform add android + cordova build. Finally add the project in eclipse again.
org.apache.cordova should now be included and everything should be working.
Replace your header with some miner changes like bellow
import com.google.android.gcm.GCMRegistrar;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.CordovaPlugin;
Step 4 in the getting started guide is the only part specific to phonegap. The rest is setting up a general android development environment. Instead of eclipse classic, get the ADT bundle from http://developer.android.com/sdk/index.html - that includes a custom version of eclipse with most of the android stuff ready to go.
The default link to cordova-2.2.0.jar worked fine for me, though it did take a bit of effort to work out that if you want to use a custom build of cordova it needs to be set up as an android library dependency in project properties.
Download apache cordova jar and add it to lib folder and classpath.

android-support-v4.jar isn't importing correctly in Eclipse

I'm trying to get an app to compile that uses the android-support-v4.jar and the Fragmentation classes it contains, but I keep getting messages whenever I try to compile that there are errors in the code. All of the errors have to do with different Fragmentation classes that are in the .JAR. I have tried ctrl-clicking the project folder and then selecting Android Tools -> Add Compatibility Library and I keep getting this error:
[2011-12-20 11:55:31 - Android Compatibility JAR not found:]
/Applications/eclipse/Eclipse.app/Contents/MacOS/v4/android-support-v4.jar
Why would it be looking for the .JAR in Eclipse's Package Contents? I've gone into the project properties and went to the Java Build Path, and imported the .JAR from the MainActivity/libs folder, that didn't work, and then I tried to import it from my SDK directory, and that didn't work. I've fixed the project properties and cleaned and built it countless times, I've restarted Eclipse, my computer, re-downloaded and installed Eclipse, the Android SDK's and ADT and still nothing. I am completely stumped.
Edit
I've gone through the build path and imported the .JAR from both the MainActivity/libs and my SDK directory. For the hell of it I added the .JAR in the directory that keeps appearing in the errors and that hasn't worked. What's making Eclipse look for it in it's Application Package Contents?
Update
So after tinkering the project contents aren't showing any errors but the MainActivity folder still says that there is one and I still can't compile.
Like nyah:
Revision
So I think the question may be "Why is Eclipse looking for the .JAR in the Eclipse Application's package contents instead of the libs directory of the project or the Android SDK directory that I used to import it as an external .JAR?"
Update #2
I am only getting one error now after tinkering, it's on this method:
#Override
public MenuItem setOnActionExpandListener(OnActionExpandListener onActionExpandListener) {
// Noop
return this;
}
The Quick Fix says that I should delete the #Override annotation but that method must override a super class method.
These are the errors that it shows:
Multiple markers at this line
- The method setOnActionExpandListener(MenuItem.OnActionExpandListener) of type SimpleMenuItem must override a superclass method
- implements android.view.MenuItem.setOnActionExpandListener
Looks like it is looking for jar here :/Applications/eclipse/Eclipse.app/Contents/MacOS/v4/android-support-v4.jar
android-support-v4.jar is found in <sdk>/extras/android/compatibility/v4
Please make sure you add this as an external jar in the java build path
I could solve this problem by
1- delete "android-support-v4.jar" from lib
2- right click on the name of the project choose "Android Tools" and "Add Support Library"
If this is still not solved:
Like already said, in Eclipse go to your Project Properties > Java Build Path > Libs > Add External and get the one from the adk directory.
Also set up Java 1.6 as your default compile version if you already haven't. This should solve the Override Errors you described.
It turns out that my Debug Certificate had expired so I just needed to delete ~/.android/debug.keystore and restart Eclipse and everything worked.
I realize that this question has been answered, but this is a known issue that is supposed to be fixed in the ADT-17 plugin release according to comment 9 here: http://code.google.com/p/android/issues/detail?id=21488
In addition, people who have this problem can copy the compatibility JAR to the location it says it can't find it. Clearly it's looking in the wrong place (since it's checking the Eclipse directory rather than the android-sdk directory), so the simple fix, for now, is simply to put the package where it wants to find it, even though it doesn't belong.
For me it was as simple as copying the v4 directory within C:/android-sdk/extras/android/support/ into the C:/eclipse/ directory.
I had the same problem running in Ubuntu. Go to Tools->Options.
Check Force https://... to http://
Open Android SDK Manager. Check Extras->Android Support Library.
Something similar happened to me. At the top of MainActivity.java I had the next imports giving errors:
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
In each of the lines on the left they had the light bulb making some suggestions. If you click on it, one of the options will be "Fix project setup". You then will be able to choose between several options for fixing the imports, you should choose the one that specifies the android-support-v4.jar.
Right click on ur project --> select android tools --> select add support library and simply installed the supporting libraries.
Do you try not to do Android Tools -> Add Compatibility Library, and only add the jar in java build path library?.
I use this jar library of this way and it works without any problem.
I had the same problem.
Under the project properties:Java Build Path:Order and Export tab, the box next to android-support-v4.jar wasn't checked. I checked the box, and the error went away.
Another caveat was running Android SDK Manager in Windows 7 without administrator privileges. It would try to install support package, but would always fail, and the actual package never got downloaded to
C:\Program Files (x86)\Android\android-sdk\extras\android\support\v4\android-support-v4.jar
Solution: Make sure that you enter the same API for "Target SDK" and "Compile with" during Android project creation (or in the Manifest file once created).

Categories