Instructions on compiling a java project from Google code - java

I use a tool called AntiSamy ( http://code.google.com/p/owaspantisamy/ ) to sanitize user input in a project. I don't know Java. I just create the object, call its method, and it works.
Recently the project was updated on Google code, but the download package itself was not. I'm looking for clear instructions on how I can download the updated code to create my own JAR file and replace the existing one in my project, thus make use of the update.
Looking at the code branch in Google code, there are many folders and other items, so I'm not sure which parts I need, and what type of directory structure I should have.
Any have any idea what should go in the JAR file/how to do this? I'm not an experienced coder, so nothing super technical please.

To build this project first checkout the sources:
svn checkout http://owaspantisamy.googlecode.com/svn/trunk/ owaspantisamy-read-only
Then change directory:
cd owaspantisamy-read-only/Java
Build the project by calling (I hope you already have maven, or get it from here):
mvn clean install
The jar you finally want is located at:
./antisamy/target/antisamy-1.4.5-SNAPSHOT.jar

Related

How to implement RichTextFX in JavaFX project

I started to work on a JavaFX project in which I want to add a copied text without to change the format and images from my driver (it should work like open office). The images should be able to be placed within the text on different positions.
Therefore, I need a controlfield which can handle a rtf format.
For this purpose I found RichTextFX. In the documentation is explained how to run RichTextFX with Maven or Grandle. I dont use Maven or Grandle, therefore I would like to know if there is a possibility to run RichTextFX without using neither of them. I added the jar file to my project and copied the source code of RichtextFX Demo. Afer that i got many errors and it is not able to run.
Can someone maybe guide me trough this problem?
I already figured out how to use RichtextFX.
For everyone who wants to use RichtextFX but doesn't use Gradle or Maven here is an explanation how to run RichtextFX-Demo:
get the fat JAR file (including dependencies)
integrate the JAR in your project
copy all classes in your project from the following link :enter link description here
add the pngs and the rich-text.css to your project from the following link : enter link description here
I can't answer other questions. I hope this helps to run the Demo.

Google OR-Tools: Using in an IDE

I have the Problem that i want to add OR-Tools into my project via eclipse IDE. I want to use the Linear Solver. I added the two jars form the downloaded Zip file. Now i want to run the SimpleLpExample from the OR-Tools site. I've got the Error that no jniortools in java.library.path. I see that at other posts they say you have to run make third_party and make java, but i don't know where i have to run these commands.
When somebody added it successfully into an IDE it would be glade when this person can explain how he does it. Thanks for help.
No. You need to add the path to the jniortools shared library I'm eclipse.
All dynamic libraries are located in the lib/ directory of the extracted archive.
To add the correct path, please follow these instructions:

Adding External jar copy to Project

I created a project but I am using an external library for it. enter link description here
I added the library to my Beans as follows:
Right click on folder "Libraries"
Add Library
Create...
Gave it a name "gson 2.7"
Picked the class, source and javadoc files.
I went on and continued programming and then I added my code to Github. Then when I cloned it my Library was missing.
How can I fix this ? How can I make it dynamic so I dont have to worry about this anymore. In other words I need to add the library to my code and not just the reference.
Thanks a lot for the help
Just upload a copy of your library to github.
I have not used netbeans, but from what I understand it adds the jar somewhere outside of your project directory, and it simply adds the location of the jar to your classpath. When you upload and then clone the project from github, the jars are not uploaded/cloned, and the project structure metadata for your project is also lost from netbeans.
My suggestion is to learn and start using a build tool like maven. It takes up the responsibility of adding your dependency libraries everytime, given that you have an internet connection. It also adds the libs to the target directory of your project folder, so you probably will need the internet connection only once. The libs will be uploaded and cloned back from the github repo everytime.
IDEs like eclipse have inbuilt support for maven, so you don't even have to worry about executing the mvn commands. Here's a tutorial that will get you intrigued - with the IDE that you prefer.
https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html
Thanks a lot for all the replies and comments.
Technically there are two approaches to my problem. For this articular example I chose to copy the external jar files to my project.
1. Copy jar files to your project.
Go to project properties
Under Libraries folder make sure to set up a libraries folder by following the steps.
Add Library at the bottom ( you can create or import; since I already had gson in Netbeans I just imported it.)
Press ok to confirm and you are done!
2. Use Maven
Go to plugings and make sure you have all Maven plugins installed, if not do so.
Create an new project and choose maven/java application
Follow the prompts
At this point you can start coding (in my case I just imported my class files from the other project)
Right click in "Dependencies folder and then "Add Dependency"
Under query type the repository you are looking for; in my case "com.google.code.gson : gson : 2.7"
Click add and you are done!
Thanks a lot to everyone for the help :)

Importing an API (UniprotJAPI) into Eclipse

I downloaded an API from Uniprot, which is a protein database, to play around with their code. This is my first time working with an API. The API contains a folder of source files (which includes example code for developers), a folder for classes, a library of JAR files, and an executable command file to run the example code (in cmd, I must execute: runExample.cmd InsertExampleCodeHere )
How do you edit this API? I tried making my own Java project, linked it to the JARS I downloaded, and also transferred over the executable cmd program to my Java project folder. At first, I copied over some of the example code, and added some print statements. When I saved my changes and executed the cmd file, my main class cannot be found. If I tried compiling my java project, I get a bunch of errors - and these errors apply to the example codes Uniprot provides (and while linked to the library of JARs). Is there a particular call (or special command) I must make when compiling my projects?
Thanks in advance!
Hmm, not sure myself as the only real API I was using was a JSON one so I could easily parse it. But, assuming you have a folder that contains of all that, I would imagine you could try to just copy it over to your project's folder and then just add it to build path in a similar vein to how you would add jars. At least that's what I can think of.
Also, you could try this which is a solution I found from the Stackoverflow question titled "How do I important the javax.servlet AOI in my Eclipse project?"
Quick Fix- This worked in Eclipse - Right Click on project -> Properties -> Java Build Path (Tab) -> Add External JARs -> locate the servlet api jar implementation (if Tomcat - its named servlet-api.jar) -> click OK. That's it !!

Putting Java code into git?

I'm programming in Java, and I usually prefer git when programming in Python. So I want to use it for Java too. I'm using Eclipse, but other people may use Netbeans or IntelliJ IDEA or whatever. How is this usually managed when putting Java code into version control?
I'm making a game which uses the library LWJGL, and that library needs to be added to the project file to be used. Therefore, I still need to check the project file into my project.
Short answer, it doesn't matter at all. Create a file called .gitignore in the root of your project file to ignore your IDE's project files or anything like that, then add your code into the git repository. For example, a good Eclipse .gitignore can be found here.
That way the other collaborators won't see your project files, and if they do the same with their .gitignore for their IDE, you won't see theirs.

Categories

Resources