I have a .jar file that is sitting in one of my folders after I downloaded it from a tutorial website. This .jar file includes all of the necessary packages needed to be imported to a specific program I wish to run (i.e., it is a client that allows me to communicate with the server I need to use for this project), but I don't know how to transfer the .jar file into a package so that I can directly import the necessary packages for this project. Do I have to transfer the file into a Maven repository (which I have no idea how to do) or do I have to use some hidden technique to transfer the file over so I can import directly from the file? Or is it a really quick fix that just takes two minutes?
F.Y.I.:
I am using NetBeans IDE 8.1 for the said-Java project.
I am not heavily experienced with all the ins-and-outs of the IDE, so I need simple instructions.
I barely understand what a Maven repository is or does. I only have heard of a Maven repo through "Help" websites.
I have tried multiple "Help/fix-it" sites but only got vague answers, like "run 'make'".
My response: How does one 'make'? Their response: ...
Related
I'm gaining my first experience with Git and its hosting platforms (GitHub etc).
Say, I create a JSP project in Eclipse with some custom files (*.jsp and *.java) and a bunch of auto-generated project files. I need to install an application server as well.
This is an example JSP project in Eclipse. Only the yellow marked files were generated by me:
My colleague wants to contribute to that project. I don't know, what system and what IDE he is going to use.
What exactly do I need to push to Git?
Are only my own files enough? Or do I need to push the entire project, including the files generated by Eclipse?
What if my colleague uses a different operating system, IDE or application server?
Would it make sense to only push the following files?
StudentsBean.java
index.jsp
How would he then need to import them, so that they become executable?
Try creating a new repo and then while creating a repo select git ignore file and type of that file is java or jsp. Then while pushing it will automatically ignore files which are not needed.
This it's probably going to be a question with a very easy answer... But I've been googling for a while and I didn't find any.
I'm working on a project that requires some classes to be used in more NetBeans projects (and EJB deployed on Glassfish and a client to call it).
Now, to make it work, I just imported the whole EJB project into the client project as a library, but everytime I launch the client, Netbeans redeploys the whole client and that takes a lot of time.
That's why I'd like to extract just those few interfaces I need from the server project, package them in a .jar and link that to the client.
In Eclipse it was easy enough (right click on your classes, export as jar). Here I can't really find anything of the sort. The only export option I see is used to export the whole project as a .zip.
(Copy pasting the .java files in the client project would also work but a .jar would be cleaner I think)
Not sure I understand the problem.
I use shared classes a lot, and package them into their own project.
Possible process:
Create new project, "Java class library".
Move the required classes to that project.
In your main project, open Properties, Libraries and "Add Project" to link to your library project.
I am about to ship a simple/medium sized java SE application to a little company.
As I am a student and mostly working on Android stuff, I never had to deal with the problem of packaging assets and folder structures within a java application.
My main concern is packaging some assets (e.g. pictures) with it. On the other hand I wanted to setup a little file structure for logs etc.
Are you using some kind of installer for that?
Or do you package the images etc. in java-packages and reference to them relatively via .class.getRessources() stuff.. and thus also setup the directory structure in the application itself?
What do you think should be "recommended practice"?
I hope this question is not to general. Thanks in advance for your thoughts.
Depending on the resources size, you can either place them in your project under the resources directory and refer to them using some getResource variation, or you can store them somewhere online (Amazon S3, your own hosting) and refer for example by web request.
For small resources the best practice is to put them inside the resources directory.
You should package your project as a jar, either by directly using the jar command, or by using maven to do it for you, but in this case you'll have to setup your project as a maven project, here's their famous 5 minutes guide.
After you have your project packed as jar (or jars) you can upload it to the maven repository, or use other sites which allow you to upload your binaries, such as bintray.
Or you can just send the Jars by email or put them on your own hosting or something :)
Try maven.
For example, with maven you can use android plugin, which can run tests and log operations for your android apps
Using maven/gradle - its core skill for all cool java developers.
I'm developing an Installer for a project team to reduce the amount of work they have to do installing it manually.
We are using:
Windows 7 x64,
Eclipse Kepler
Right now I'm looking for a way to import a .war file using the commandline.
Is there any way to do this via cmd?
First of all, I would not recommend importing the source code from a file in Eclipse if you have a team of developers, as you would be giving everyone a version that will hardly be actual after some days of work. Using some repository (CVS, SVN, GIT) would be the way to go.
If you have your code in a central repository, then you could make a "Project Set" file in Eclipse wich can be imported easily to setup your whole workspace:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-cvs-project-set.htm
This project set might have instructions on how to construct the Workspace based on checkouts of the repositories you need.
If you happen to work at a company that uses some X or Y old-fashioned Source Control tool (or worse, none at all), and you have no chances of implementing one that is compatible with Eclipse (like the three I stated above), then the time you are saving with automating the import of a war file will become irrelevant compared to the source code control issues you will be facing (or the team is facing already).
A WAR file is a ZIP file. If you need the content of the WAR you can use the tools for ZIP archives.
A workaround in case eclipse does not have any such options would be to
do a Import WAR through eclipse GUI
check what changes are made to workspace by eclipse (eg. folder created with exploded war file content, configuration files created by eclipse in the folder like .classpath for project folders etc)
Identify the steps and replicate the same through a batch file
Add a call to the batch file in eclipse launch short cut
There is no command line API I know to do this task for Eclipse just from command line, but with the right tools you can achieve what you want.
Please try this:
Straightforward approach that works with any GUI application. You can use AutoIt scripts for interaction with any application. The downside is that GUI may change more frequently than command line API.
Try to create Eclipse project with metadata and unpack WAR file in this project. It can be done, for instance, with Maven or Gradle. Those also can download all dependencies for you.
i'm new to java and i got some problems. i'm developping a web application using the framework stripes on tomcat 6.0.
I'm working with eclipse EE on windows. i successfully managed to get the stripes example application (called Bugzooky) up and running on my tomcat server. I imported the .war file and stripes libs in Eclipse.
Here is the stripes archive containing the examples and libs
But now i'm trying to change the example source files to learn how does it work. but whatever the modification made to the source files "WebContent/WEB-INF/src/*.java", nothing change! even after restarting the server. i noticed that the classes are compiled into .class files in the "ImportedClasses" folder, and tomcat always use these files, they are never updated, and if i removed one of them, the application just don't start. it look like my source files don't exists!
I also tried to build my webapp from scratch, but when i tried to use the features used in the example files (like SecurityFilter.java):
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import ...
It ends up with plenty of:
the import javax.servlet.Filter cannot be resolved
I checked the Librairies and it look like i'm using exactly the same as the example.
It's probably something i didn't understood about java but i googled 100 times yesterday, and i can't find the solution (i probably didn't search the right place because i don't really understand my problem).
I hope you'll be able to help me.
I'm not sure about the first problem. With regard to the problem when creating a new project:
the import javax.servlet.Filter cannot be resolved
This means that the web project in Eclipse is not associated with an application server. If this is done correctly, then Eclipse will automatically include the server's libraries (the server is actually a concrete implementation of under each the Servlet API) in the project's buildpath.
Did you integrate Tomcat in Eclipse? You can add servers in the Servers view at the right bottom box. Did you associate the web project with the particular Tomcat instance? You need to select the server in the Targeted Runtimes section of the project's Properties. This is by the way normally to be done during creating the Dynamic Web Project.
You need to recompile all the changed .java files, rebuild the .war file and redeploy it to Tomcat. This is most easily done with an Ant build script. Look for a file called build.xml. If it is there install Ant if you don't already have it installed and you can then just execute the ant command in the directory with the build.xml file and then copy the resulting .war file over the existing one in Tomcat. This is all basic Java App server work flow stuff.