proper way to configure a project in eclipse for eSWT? - java

can someone direct me on how to configure a project in eclipse so that i can utilise eSWT.
Just by manually adding eswt-converged.jar gives me build/pre verification errors.
I downloaded this and utilised the jar from the folder and copied it to my project folder and added it to the build path.But it shows me something like
Please help.
EDIT
i did what Neil said and i am getting this now:

I see that in the link you provided, there are a number of other jars that I don't see included in your project. If I had to take a guess, your jar is heavily dependent on these jars which aren't there, so all the classes that it uses which are defined in these jars simply aren't there.
Though, without further information on the nature of the problem, it's difficult to determine anything else I'm afraid.

Related

Unable to launch a java/javaFX code after a clone on IntelliJ

It's very complicated to explain so sorry if it's not clear. Basically, I'm on a group project in javaFX, and every time I clone it, my PC doesn't recognize either Java or JavaFX on THAT project exactly. All the others work fine. So I have to do a lot of manipulation each time for it to "work" (I explain below).
And today I have clone because of an error. Except that impossible to make it work again.
What I did on IntelliJ after cloning:
-I reloaded the MAVEN project
-I imported the java libraries
-I put the right folder in ROOT
-I created the configuration
From there, Java and JavaFX are recognized. After that, I have other problems. In particular that of "The output path is not specified for module structure" and after that it redirects me to File -> Project Structure -> Project and compile output. Except that in my previous problems, I didn't have to define a Compiler Output. Usually the steps above were enough. And the problem is that I have no idea what to put in this section. I searched all over the internet, but 90% of the time it's an old version of IntelliJ and it was asking them for a path. There, I am asked for a file (impossible to choose a destination path, it is greyed out). And in CTRL C + V the path directly (for example an excluded "Out" folder like what I have read on the internet), I have this error at launch:
Error occurred during initialization of boot layer java.lang.module .FindException: Module start.structure not found
I want to re-specify that there is no error in the code, we have exactly the same with my team, and with them it works without worries.
If someone know how to resolve theses problems
This isn't really fully answerable here in a general sense, because there are too many environmental and project-specific things that may occur.
Instead, I'll provide a suggested approach for a new project:
Create a new JavaFX project in Idea.
Choose Maven for the build tool.
Follow the execution instructions from the linked documentation to ensure the project runs in your environment.
Share your new JavaFX project on GitHub.
Clone the newly shared project to a new Idea project.
This is emulating somebody else checking out the project from GitHub.
Run the newly checked out project in your Idea environment exactly as you did for Step 1.
That is really all you need to do to use JavaFX + Idea + GitHub.
A pre-existing project may require additional steps for configuration and use which may be project specific, so I can't generally advise on that.
Some comments on the approach outlined in your question:
You mention "every time I clone it".
You only really need to clone a project once, after that you can just update it.
The image has a folder ${project.build.directory}.
That looks wrong, kind of like an expansion variable name was applied literally rather than being expanded (I don't know what you did to cause that).
Your resources folder isn't marked with a resources icon.
This indicates that you haven't imported the project from Maven correctly.
Normally Idea will recognize a Maven project and import it automatically, mapping the standard directory structure, e.g. src/main/java is Java source and src/main/resources are resources.
"I have put the right folder in ROOT"
I am not sure what that means, but it should not be necessary to manually configure things like this. As mentioned, Idea knows the standard Maven project structure and is able to apply it without manual intervention.
"I created a configuration."
You don't need to create configuration manually.
The configuration you have created is wrong.
If you right-click on your JavaFX application class and choose run, an appropriate run configuration for the application will be created automatically.
The configuration does not need to specify a JavaFX SDK.
You don't need to (and should not for this purpose), install a JavaFX SDK on your machine.
The configuration does not need to specify a module path or modules to add.
Idea and Maven are smart enough to know that:
your application is modular (because you have provided a module-info.java)
the required modules are provided as Maven dependencies (this includes the JavaFX modules that you need)
the modules should be placed on the modulepath (Idea and Maven will do this automatically, you don't need to do anything manual for this to occur).
For the message "The output path is not specified for module structure":
I don't know what this means, but, if you follow the suggested approach, you don't need to manually specify an output path, Idea and Maven will automatically assign appropriate values and use them without user intervention.
"Error occurred during initialization of boot layer java.lang.module .FindException: Module start.structure not found"
This indicates that you have specified somewhere that a module start.structure should be used and either:
Your application's module (specified in its module-info.java) is defined using a different name.
Your application's source code is not on the module path (perhaps it is mistakenly on the classpath instead).
Your apps module isn't correctly added.
Usually Idea will be smart enough to know that you have a module-info.java and therefore to place your application code on the modulepath, so you don't need to manually specify modulepath and add-modules options to find your application's module.

No source code is available for type com.google.gwt.ajaxloader.client.AjaxLoader;

I am migrating an project someone else built to newer packages and I have traced the root of my errors to this
No source code is available for type com.google.gwt.ajaxloader.client.AjaxLoader; did you forget to inherit a required module?
I am new to GWT and not really sure how it works 100% under the hood so I am having trouble applying solutions to similar posts to solve this error.
go to Maven Repository and get gwt-ajaxloader.jar - it contains both .java and .class files
save the jar to war/WEB-INF/lib folder in your project
right-click on the file in Project Explorer (I assume you use Eclipse), select Build Path -> Add to Build Path
enjoy ;)
GWT needs source code as opposed to .class files to do its work.
So any references you might have from your client code towards any jars, etc, need to also include source code.
In your case, you either need the source of com.google.gwt.ajaxloader.client.AjaxLoader, or remove any references towards the mentioned class, from your GWT code.

Cannot resolve json import Intellij after adding dependency and library .jar

I cannot seem to resolve this issue after adding the json-lib-2.4-jdk15.jar from an online source to the project dependencies, screenshots provided to show walkthrough of what I am doing. (and yes I have repeatedly tried "Invalidate caches and restart")
The error:
This is my Project Structure ("cmd + ;" or "File > Project Structure")
It doesn't seem to work on "Scope" set to Compile either. Note that I added the .jar file as a library too because I'm just really unsure as to why I can't get this to work. Any help is greatly appreciated, thanks.
What do I seem to be doing incorrectly here?
The jar you have downloaded from https://sourceforge.net/projects/json-lib/ doesn't contain the classes you need. This jar contains net.sf.json package which is a different implementation of JSON Java library.
You are trying to use org.json.* classes which are provided by another library. The library you want to use is this one: JSON-java. At the bottom you can find the link to the Maven repository where you can get the jar file.
The latest version (at the moment of this reply) direct download link for the jar is here: json-20160810.jar.
Add it to the module dependencies and your problem should resolve.
Next time you observe similar issue browse inside the library jar under External Libraries node of IntelliJ IDEA project view and see what classes it contains and under which packages. This way you would know if the issue is caused by the wrong jar you've added to the dependencies and which doesn't actually contain the classes you want to use.

How to get rid of library references issue in netbeans? Java

I created a web application and it used several libraries once upon a time. So i added them but later on i found alternative and actually better way to do the same things. So I removed references from my project for those jars and libraries. Everything works fine but when I move the same project to my friend's laptop Netbeans 6.8 simply doesn't let me deploy the project and gives the whole bundle of errors of libraries that I used previously but I don't use it anymore.
I removed all references from build.impl file and then when I deploy it, it works fine. But when I do a clean and build and try to deploy it, build.impl automatically again adds those lines of xml which contains references to libraries and again gives me a whole long list of errors. How do I get rid of this? I am really tired of these silly errors.
Thanks in advance :)
You might think about switching to a build system which does dependency management. Maven is natively supported by Netbeans and solves these problems effectively (you get some new problems in place but thatis another story).
There are others, Ivy, Gradle, ... but are not as integrated in Netbeans.
In the pom.xml you have a listing of dependencies which have their dependencies. Maven will walk the dependency tree and get the jar's from a public repository and stores them in your local repository. 3rd party jars which are not publically available can be stored there too, but your friend will have to add them to his repo too. A little script in the root project folder can do wonders here (or your own shared repo, but that is more heavyweight)
Almost all libs can be removed from the lib folder which reduces the size under version control, speeding it up.
Netbeans, Idea, Eclipse+m2eclipse the synch their files on the POM.
Now maven does have its warts, when you try to do things with it slightly left of what it thinks you should do.
What I would do, is to remove all netbeans specific files and re-create a project from scratch using existing sources on your friends' laptop.

Tool to remove unnecessary dependencies in a Java project

I have a Java project that currently has a lot of JARs in its libraries directory, which are all included in the resulting package when building. I know, however, that some of these libs are never referenced in the project.
Is there a tool that can search for libs that are not referenced within the project? I guess there must be something in that sense.
BTW, an Eclipse plugin would be awesome.
EDIT: I chose to go with ClassDep because it was the only suggestion that worked. However, I'm having some trouble with it: please check this question
Beware of the case that a class is loaded via Class.forName() and not specified as a dependency in the manifest file (there is a Depends-On: attribute that is for that, but many people don't specify it, which breaks tools like this, the bane of my existence when I worked on such a tool).
ClassDep (from Sun, in the Jini development kit) will do this for you.
ClassPathHelper can help you with that.
Espacially the "Not on Classpath View"
This view scans for jars that are not on the classpath (but are under the current project). It provides basic browsing of packages and classes that are available but not on the classpath. This can be helpful when trying to build up a classpath, as you can quickly browse for the missing classes to see which jars contain them.
Not an eclipse plugin, but I believe the "shrinking" functionality of ProGuard is exactly what you're looking for.
I wrote a small eclipse plugin that takes an existing java project from the workspace. For every classpath entry of the projects raw classpath it removes it from the projects raw classpath and builds the project. If no problem markers with severity error appear on the project, it permanently removes the classpath entry from projects raw classpath.
I'm not able to share that plugin, but that is not too much work to implement it yourself with the links to the api given above.
You also can't tell if JARs that you don't import are required dependencies of dependencies. For example, if you use Spring it comes with its own dependencies, even if you don't import or call those classes in your code. I'm ignorant of ProGuard - does it check for those cases?

Categories