we have some dependency xxx-1.0.jar with it xxx-1.0-source.jar (built using maven) real sources was lost, but xxx-1.0-source.jar contain source.
Now I need make some changes in this source, any easy way to do it and compile back?
if it is built with maven and if you have both compiled and source jars, there is an easy way to do that.
create an empty folder with your project name and create following folder structure.
MyProject
|--src
| |--main
| |--java
|--pom.xml
After that extract the complied jar and you should be able to find pom.xml file within META-INF folder. copy and past it to your project pom file.
Then extract source code jar file and copy source code into src > main > java folder which you have created.
Now you can open your project folder with any IDE as a maven project. You can build it by running command mvn clean install
Your question is pretty generic, so here comes a generic answer:
extract that source code JAR
create a new project in your favorite IDE
import/load that source code
keep massaging until it compiles
understand the required settings, and turn your project into a "built system" built thing
In other words: you still have the source code, now you probably have to re-build the meta information that is required to compile that source code successfully.
Related
I'm a beginner, when I create a java project using the command pallate in vscode ctrl-shift-p -> java: Creat java project, only created the lib, src and readme files, I see on the vscode website there must be a .settings, bin, src folder .classpath .project
is there anything to configure again? thank you
my create project
create project on vscode web
Those files you mention (.settings, .classpath, .project) are just metadata files from the IDE, and java does nothing with them, they are not part of a java project, the only thing you need to create a java program its a .java file. If you want to create a project, there are better ways, for example using maven https://maven.apache.org once you installed it, you can create a new project using the QuickStart archetype
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
It will create a standard structure for your project, and will save you a lot of work with the structure of your project, dependencies and build configurations.
To store project metadata some IDEs use additional files:
Eclipse uses .settings, .project, .classpath
Intellij uses .idea, .iml, .ipr, .iws
You don't need any of these for your project to work. If you use VSCode you don't need them at all.
Most modern java frameworks have quite comprehensive code generators for new projects which makes it easier to get started e.g.:
Quarkus
Micronaut
Spring
I have a basic but important question.
Our client has an application that has been written with JAVA. We need to modify something in one of the classes.
They passed us the Source files of this project, but I really have doubt that if they sent us the source or no!
This is the structure of zip file:
But when I import it to Eclipse (Import Existing Project to workspace) I see the error that is saying: "No projects are found to import"
How can I be sure if they sent us the source?
Actually I want to be sure and then ask them...
I tried also to open it with Apache Netbeans but it says "No Netbeans projects added".
Can anyone help me about this?
Thanks
Sep
The complete build structure does not look like a default gradle/maven or even Eclipse/Netbeans IDE style (as mentioned already by greg-449)
Howto import plain sources into Eclipse - without maven or gradle
Normally a eclipse project setup looks like
/.project
/.classpath
/src/java
Hello.java
/test/java
HelloTest.java
/bin
Hello.class
HelloTest.class
So I would do following
Create a new Java Project in eclipse and use as customized project location your root folder of your source files.
When asked for source folder location you can either use /src/java (when you
you are free to restructure the files), or add all folders where
sources are located (e.g.maybe nbproject contains sources ?) as source
folders of the project.
Libraries: If the project contains dependencies and you want no compile failures, you must add all libraries to your eclipse project. When you can start the (ant ?) build you will have all libraries inside build folder. Add those to your eclipse project at the build path properties.
After project creation + build in eclipse, the files .project and .classpath are created. Inside the project you should now see at least your sources inside java source folders - and maybe you are able to start the application.
For more information see also
https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-3.htm
https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-wizard-java-project.htm
Thanks everyone,
I did not found any .JAVA files in the source so I am sure that they did not pass me the complete source file!
Thanks
Sepide
I try to create a maven project of a java program, which includes two java classes and a fxml file, which are all located in the same directory (src/main/java/package).
When i install the project with maven it does not copy the fxml file into the .jar file so that the program does not work any more. A few hours ago I basically created an equivalent project and everything worked fine.
How can I fix that?
The Maven convention is that Java files go in src/main/java. Any non-Java files go in src/main/resources.
The Eclipse emulation of Maven does not make this distinction. Both directories are source folders which is incorrect but "good enough" to handle correct Maven projects.
So, move your file to the correct location.
I'm working on a Java project for which I need a very specific testing code, which I create in Jasmin, the JVM assembly. The project is built with Ant and has a nice directory structure, namely:
root
/src
/classes
/tests
/build
/classes
/tests
The tailor-made Jasmin source file is in the src/tests directory, together with the JUnit Java files. All of these get built with Ant (I use the simple "java" Ant task to run the Jasmin compiler on the source file), they're put into respective directories inside the /build folder, and Ant then runs the JUnit tasks. All of this works fine...
Until I introduced the single Jasmin-generated class, Eclipse worked perfectly with the project. The problem is that Eclipse doesn't see the new .class file. The Build Path contains src/classes and src/tests as source folders, and /build as an output folder. Yet it doesn't seem to be able to find the class generated by Jasmin, so there are hundreds of "ClassX unresolved" problems and it really makes developing quite painful.
Does anyone have an idea how to force Eclipse to see this class?
A simple solution would be to compile Jasmin classes into a separate class folder and then add that folder into Eclipse's build path: Project Properties / Java Build Path / Libraries / Add Class Folder...
I have a project that shares models with my android project. I have a separate eclipse project just for models and other shared code. I add this to my play project as a dependency in eclipse.
In eclipse, play compiles and starts without problem. However, I went to deploy to GAE and found that the compilation stage of play's packaging fails because it can't find the models.
I suspect I could hack the ant build files, but that seems brittle.
Is there a standard way to add extra directories to the play compilation source tree or the classpath?
Make a jar-file with your classes and put it in /lib. That's where I put my libraries.
Files in the application /lib folder is automatically added to the class path by Play Framework. See Classpath settings
From Anatomy: "The app directory contains all executable artifacts: Java and Scala source code, templates and compiled assets’ sources" ... and further: "You can of course add your own packages, for example an app/utils package"
You can copy java source files to make a hierarchy of packages under /app, e.g.:
/app/sharedcode/project2/models/domain1 and import that in WhateverController.scala as:
import sharedcode.project2.models.domain1._