I'm quite a noob programmer and I recently discovered Java Processing Language which can be run on Android.
So far I've been using a dedicated IDE to program it in but I've just found out I can program it in Eclipse which is my preferred IDE. The only problem is that they only tell you which libraries to import when creating a Processing project from a standard Java project. So every time I want to create a new project I have to create a Java project, go through all the import menus, search for the Processing system library, import the files, create a new class and import the library for the class.
Does anyone know how to create an eclipse plugin so I can just go to the NEW directory in eclipse and have a PROCESSING folder and a NEW PROCESSING PROJECT item that already has a generic class with the imported libraries?
I've been looking at online tutorials and I can't even figure out where to start.
The steps to create a Processing project from a Java one are explained here.
Thanks for any help!
I recommend having a look at the Proclipsing plugin which seems to do pretty much what you want to achieve. It's also open source so you can see how it was written and modify if you like.
A Processing project is a standard Java project with the Processing libraries added to build path. There is nothing more to Processing in this regard. So a specific Eclipse Processing plugin for this seems overkill (there are some other things like the different targets or samples that could make it useful though).
To easen up your current process: Create an Eclipse User Library for the Processing libraries. Menu Window > Preferences, Java > Build Path > User Libraries, New.... Add the Processing libraries. Now you can easily add the whole set to a project (right-click on the newly created Java project in the package explorer, Build Path > Add libraries > User Library).
If you want to change the standard template for Java classes to one including everything for Processing: Window > Preferences, Java > Code Style > Code Templates, Code > New Java files. This changes every newly created class, maybe it is better to just create a simple template to manually call at start: Java > Editor > Templates, New.... Then you would call the template every time you create a Processing main class but not for "normal" classes.
Ok... regarding the target audience of Processing a plugin may be a good idea. But then there is the dedicated Processing UI. Eclipse is not exactly a good introductory IDE.
Related
I want to create a multi-module Java project, in NetBeans 15.
By "module", I mean the Java-9 "modularity" feature, where each module folder has a module-info.java file that specifies its exports or depends or etc.
I know how to code a multi-module application. I just don't know how to do it as a NetBeans project. Yet I'm sure that lots of you StackOverflow readers have been there, done that. How can I do that, too?
Also, I am not using a plug-in, I am not using JavaScript. I am not using Maven, but Ant would be OK.
There is a complete tutorial at https://netbeans.apache.org/tutorials/nbm-projecttype.html, but this shows how to create a NetBeans module, for the NetBeans IDE, so that is the wrong place to look.
Got it! I've succeeded, I built a modular project in NetBeans.
But first, I had to understand how modules work in Java. I kept my coding as low-level as possible. I used only non-IDE file explorer, NotePad++, and Windows Command Prompt. Instead of automating the process with CMD scripts, I stuck with Java's own #argfiles. The strategy was KISS (Keep It Simple Stupid), even though the typing was brutal, I really really had to watch where and what I was typing. And plenty of times, I wished I had the NetBeans "Tools" and "Edit" features. But finally I am ready to turn to NetBeans.
Yes, NetBeans does modules!
Follow these steps:
New project > Java with Ant > Java Modular Project.
Project Name and Location is your choice.
In the "Projects" window, right-click the name,
New Module, and add the module name
In the default package, right-click, and
add your packages
add your classes
code your module-info
another New Module etc etc
eventually you'll get your modules in. NetBeans is good at catching typo's and missing items.
run your multi-module program!
All this procedure is almost as easy as writing a non-module program. The extra layer of modularity should be logical and functional. For my project, I had to think twice about module boundaries and names.
So! It's working. The NetBeans IDE and debugger are working for me.
I'm trying out Java 9 Jigsaw module system (no module experience yet) and would like to use it for capsuling the classes within my project, but it's confusing.
According to this article it should be possible to have multiple modules within ONE project. I made a new project in Eclipse Oxygen (Java 9 is supported) with the same structure as shown in the article. But Eclipse keeps telling me that I must not have more than one module-info.java in a project.
I really don't know how to tell Eclipse that it should use the "multi-module-mode". And I really would appreciate not having to create a new project for every single module.
This works:
This not:
But according to this article something like that should work:
And how about deployment of a modularized project with Eclipse? There is nothing to see about the new jmod extension. Do I still export it as a runnable JAR file like before?
Notice that my questions refer to working with the IDE (no command line, I mean with an IDE that should be possible, right?) Thank you for enlightening me.
Currently, Eclipse requires you to create a separate project for each module (e. g. because each module has its own Java Build Path).
To understand this design decision, consider that Java modules correspond to OSGi bundles / Eclipse plug-ins and it has always been to have a separate project for each bundle/plug-in. If you come from the Maven world, you would probably expect a deeper folder structure instead. But modules are self-contained and combining several modules into one project would only add an additional folder level without meaning. However, Eclipse supports nested projects and so-called working sets if you need an additional folder level.
Exporting modules as images is planned for Eclipse 2019-03 (4.11), on March 20, 2019 (see Eclipse bug 518445). Exporting modules as JARs that can be used on the modulepath (-m) already works (see my video).
I don't know if this question is still open for an answer, but you can solve this problem by simply removing all source folders on the build path. At least this works for Eclipse 2021-12 version.
As you can see this is a demo project from the Official Gradle Guide Book and it has multiple modules. Each module has its own module-info.java.
project structure in IntelliJ IDEA
If I open this project in Eclipse it will give me the 'duplicated entries on module-info.java' error.
Eclipse shows the error
But if I delete all the source folders on the build path, the error is gone and the project can be built and run without problem.
project properties: Java build path
The only problem is that you have to build the project with Gradle so that it will produce the .jar of each module and you have to include them in the libraries later.
include all the .jar in libraries
I think this is probably the same solution mentioned by howlger above.
As stated in the title: I want to run an Eclipse-Plugin, more specifically a GEF-Editor, without starting an Eclipse instance before.
I've tried to use the export functionality provided in the MANIFEST.MF file:
However, running the generated JAR (call it editor.jar) by executing java -jar editor.jar on the command line fails with the message no main manifest attribute, in plugins editor.jar.
I'm aware of the fact, that this is because my MANIFEST.MF file is missing the following line
Main-Class: <packagename>.<classname>
which defines an entry point for my application. However, I've no idea what exactly I need to do here (in the case of an Eclipse-Plugin), cause I don't have something like a main method. I assume Eclipse is running some magic code it doesn't show to me, when I start my project as an Eclipse Application.
So, what do I need to do?
You could try running a GEF editor as a Java application. See Draw2D examples to understand how it can be done. You could probably re-use your GraphicalViewer and PaletteViewer, which means that mouse based interactions with the diagram and palette will be preserved.
However, your editor class would probably have to be incorporated into an SWT shell. Also, all actions contributed to by your editor into Eclipse toolbars, popup menus etc. would be gone. Outline and Tree view would have to be incorporated into your java app somehow if needed.
Think you'd be better off with an RCP application.
Wrap your GEF editor in a simple RCP. You can create one via the Plug-in wizard, setting "Would you create a rich client application?" to "Yes" in the process. This gives you the option to create a minimal application via the Hello World template in the next step. Once you have this, you can either embed your GEF editor in this plugin, or declare a dependency from the new RCP application to your GEF editor plugin, and start the editor from the Application class' start method.
For an overview of resources about RCP development, cf. Getting started with the Eclipse RCP.
It really doesn't add that much overhead to your editor but gives you the opportunity to work with the platform's workbench and workspace metaphors and create easy-to-deploy-and-use application bundles.
Once you have that in place, you can test your RCP from plugin.xml > Overview > Testing > Launch an Eclipse application. This will not run a whole new instance of the IDE, but just the RCP application itself.
Rather than exporting from the MANIFEST.MF, look into creating a product (you can do it via the wizard: New > Product Configuration), and building it via the Maven Tycho plugin(s) (have a look at the respective - really worthwhile - tutorial from EclipseCon Europe 2012: http://eclipsecon.org/europe2012/sessions/building-eclipse-plugins-and-rcp-applications-tycho.html, this includes a section on creating a product as well). Tycho gives true cross-platform builds, as long as you're not on Windows.
No magic code there :).
I have recently started using Netbeans C/C++. I see that the new file wizard doesn't show any buttons to create java files, all of them disabled. I can create java files in a Java project however.
If I create a java file manually and open it inside the ide, it provides syntax-highlighting. But the IDE doesn not show any wizards that will enable me to create new java files inside a c/c++ project.
How can I enable this ?
You can't create Java files in a C / C++ project (and vice versa) . You have to use either Java or C(++).
I don't see a reason why you should mix them, but better you develop your Java code in a Java Project and same for C/C++. However, you have to move manually.
Btw. please explain your problem more detailed, it's hard to understand why you put two (or 3) totally different things together.
An observation, rather than a solution...
We need to support mixed language projects because the dependancies between artefacts-by-language can go in both directions.
For example: Java classes are used to generate JNI headers (javah) for C/C++, while C/C++ headers/libraries are used to generate wrapper classes (swig) for Java.
This represents a bidirectional dependancy between single-language projects, but not between artefacts in a single mixed language project - i.e. the build can be described by a DAG and thus satisfied by make.
I'm creating a Java project which includes a few libraries written by myself. However these libraries are not finished and sometimes require some edits. Because I'm working by myself, I find this more efficient than finishing all libraries perfectly before using them in my project.
My question is: is it possible to automatically rebuild a modified library when building the project which uses it?
Subquestion: what is the optimal configuration for my purposes? Should I export libraries as jar and copy them into the final project or should I configure buildpaths of my project to retrieve them in their respective folders?
Subsubquestion: is it correct to use .jar libraries in the same way that one uses dynamic libraries in c++?
If you have Eclipse set to "build automatically", it'll take care of rebuilding the library projects whenever you make changes, as you go along. You should set your client program to depend on either the Eclipse projects (if doing everything inside Eclipse) or the Maven artifacts (if using m2e). I strongly prefer using Maven for all my Java builds, but it might be overkill for something small. Whatever you do, don't manually export and reimport the libraries.
All libraries in Java are dynamic, and a C++ .so or .dll is the basic equivalent.