Create a EAR file compiling and getting compilation errors in eclipse - java

Well, I has a doubt about compiling a java project into eclipse.
Note: My project is not using maven.
If i want to get a .ear or .war file what is the way?
I want to compile my project and get all compilation errors, because I change my jdk version, from jdk 1.5 to jdk 1.8
And this is why I want to compile it getting my compilaion errors, to fix them and get the ear or war files
I mean, may I compile from project -> clean -> built automatically
And this gonna give me this kind of files?
Or i have to compile it from command prompt?
Hope you can help me, any idea is a good one.
Thanks a lot.

you can use Export option to create WAR or EAR file provided the project is created as Dynamic Web Project or Enterprise Application Project.
switch to java 8:
1. add JRE 8 libraries into your project classpath
2. change the compiler version to 1.8
Then select the Project->Build Automatically. you can see the errors in Error Log View or Markers View

Related

No Java code completion in VSCode in gradle project

I am trying to setup my VSCode to get proper code completion in this project: https://github.com/structurizr/java-extensions
I have the Java Extension Pack installed in my VSCode.
But it is not even recognized as a Java project. If I add every single "src" folder via "Add folder to java source path" the Java imports are recognized but the code completion is still not working.
Any hints on what is wrong or what I need to configure in my VSCode to make it work?
Thank you
Because this is a Gradle Project, In addition to Java Extension Pack, you should install Gradle Language Support.
Then reopen the project in VS Code, Gradle extension will download the required files to be able to build and compile the project. After all downloads finished, you can edit your project and auto-completion would work as normal:

JavaFX runtime exception but all JavaFX jars are correctly packaged into my JAR?

I am using Eclipse 2020.03 and Java JDK 13.
I downloaded the appropriate JARs from the JavaFx download site.
When I run my project in Eclipse, there are no errors.
However, when I export the JAR and run it, the program encounters a runtime error that reads
No toolkit found
Here is what my JAR looks like when I change the extension to a .zip and open it:
Clearly, all of the required JavaFX library JARs are in there.
I have also tried using the export mode where Eclipse extracts the library JAR source code into the exported JAR but the same error occurs.
What am I doing wrong?
Edit: I am not open to using Maven.

Cannot get simple Spring application to work

I'm not sure what i'm doing wrong here... i downloaded this sample project which is basically the simplest possible working example of an annotation based controller. I downloaded Tomcat and started the server no problem in eclipse. I downloaded Spring 4.3.7 from here (i'm not using Maven nor do i want to). Added as external JARs under libraries.
When i go run the application i get a ClassNotFoundException for the ServletDispatcher class so i followed the instructions here to resolve this. But when i add the Spring JARs then my server times out with the following error sure enough in the deployment assembly there are being deployed to WEB-INF. So i removed the JARs, and i added them one by one based on the ClassNotFoundException. First i added spring-beans, then context, then webmvc and it seems when i add core this is when the error switches from the ClassNotFoundException to the server timeout error... I'm not sure what to do?
EDIT: Found out that my compiler was set to 1.7 while my JDK was set to 1.8. I changed this and now get a java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable error. I tried adding the core JAR but then i continue to get the server timing out error.
In Project Properties.
Check your java build path it should contain
JRE system library: JDK 1.7 or above
Server Run time: Tomcat
Check your Java Compiler
It should be 1.7 or above
You need to add the Java build path in the Deployment Assembly
1) Right click on your project, select Properties
2) Select Deployment Assembly. Click Add button.
3) Click on "Java Build Path Entries"
4) Select yours jars
5) click Finish
Clean build your project and restart tomcat.

Android: java.lang.NoClassDefFoundError after importing jar. Wrong jar?

After I've imported jar file into Android project and ran it, I get java.lang.NoClassDefFoundError At first I thought that I'm doing something wrong while importing it, but then I tryed to import jar that I've from some online class and it worked! So here is my question:
Is there any specific way of creating jar files for Android project?
I've to point out that first jar is created from Java class that I wrote some time ago. This jar works without problems in another java app. The jar was created using Eclipse Kepler.
Thanks for your help.
The solution shoved up to be pretty simple. Currently I'm using Java 1.7 to create my jar files, but Android accepts only jars that were created with Java 1.6. So the problem is caused probably by some incompatibility in bytecode and therefore you need to force compiler to use Java 1.6.
If you're using Eclipse, go to Project properties > Java compiler and select Compiler compliance level: 1.6 Save changes and rebuild your project. You're ready to export "working" jar :)

Not possible to export EAR file from Eclipse 3.6.2

I have written some Java code that I need to export into an EAR file. I am using Eclipse 3.6.2 I have looked at
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jst.j2ee.doc.user/topics/tjexpear.html
but the problem is that I do not have the export destination "J2EE"--> EAR file in Eclipse.
Also when I go to New--> File --> Other there is not such an option. I did add the JAR-file "ejb-api-3.0.jar" to my project though and Eclipse does not give me any errors.
What am I doing wrong?
You have to use Eclipse Java EE for making War Files. You can also add the required plugins into your existing Eclipse but downloading the Java EE version would be much easier.

Categories