implementing the NWalign.java alignment script for needleman wunsch algorithm - java

I'm trying to run the NWaling.java file found here. the code present at the link that I mentioned makes use of the jaligner library. I have downloaded this Java package from here. inside the zip folder there is a JAR file. I'm developing the code using eclipse. whenever I add this JAR file to the code there are some classes missing for example:
import jaligner.NeedlemanWunschGotoh;
&
import jaligner.matrix.MatrixGenerator;
also in the entire zipped folder there isn't any pom.xml file to allow me to import the entire folder as a maven project to eclipse. can somenone suggest me how to import this jaligner library and use it in eclipse? thanks.

You can download a community implementation of the jaligner algorithm from here.
Take a look at this project sources where you may perhaps find all the searched artifacts.

The full Eclipse project with the NWalign.java can be found here including .classpath file with all dependencies listed there.

Related

Import processing.video.* on Intellij

I am trying to run a mp4 video in Java using Processing.
I'm trying to use Intellij IDEA, but when I try to import processing.video.* it doesn't find the video library.
Where can I find and how can I import this library?
You need to do two things:
Find the .jar files (and any other files) required by the library.
Add those files to your classpath.
You can find the library files in your Processing directory. For me mine are in C:\Users\kevin\Documents\Processing\libraries\video\library, but it's going to depend on your OS and where you installed Processing.
You can also build the library yourself from this GitHub repo.
Now that you have those files, you can add them to your classpath. Since you're using Intellij, the links in Slaw's comment should get you pretty far:
Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project
Working with libraries - Intellij

IntelliJ ctrl-click references a .class file not a .java file

I have the following line of code in a .groovy file for testing:
GenerateShipConfirmsForBatch gscb = new GenerateShipConfirmsForBatch();
Ctrl-clicking on the GenerateShipConfirmsForBatch takes me to GenerateShipConfirmsForBatch.class in a .jar, and not the .java file, even though I have the class correctly imported at the top. I want it to reference the .java file so it will pick up changes I make to the .java file.
Any help would be greatly appreciated!
First guess - Wrong import
What you wrote seems to me like you have class with the same name in 2 different packages or in imported project instead of in open-able java class. When you import class be careful that you import the one you want to use.
Eg. annotation class Service is wildly used in different packages.
import org.springframework.stereotype.Service;
import com.google.web.bindery.requestfactory.shared.Service;
Just check that you are using the correct import.
Second guess - Incorrectly set modules
If you are having the multi-module application you have to set correctly the parent project to properly address this issue as well as child projects where the links should be as well.
In Maven it is done using pom.xml. It is very nicely addressed in Maven - Guide to Working with Multiple Modules.
In Gradle it is done using build.gradle. You can read more about it Gradle Multi-Module Project Setup.
Basics about classes
Local class
Idea is linking local .java files in preference instead of .class therefore if this is happening I'd recommend reinstalling Idea as I cannot find the correct approach.
Linked class (from external library)
If you have imported external library it WILL link to .class as it is decompiled from .jar file.
What you can do is either download .jar with source codes, if you are using Maven Projects click on Download Sources and/or Documentation.
Just because you have the class imported at the top does not mean that you can view the source code (e.g., .java file). If this class is coming from a dependency defined in your pom.xml or build.gradle file then you likely won't have access to view the source code. However, if this is a separate module you have at the top level of your project, then you'll be able to view the .java file. If this library is open source then I'd suggest cloning it in your project and adding it as a module. That will solve your problem.
You can install Java Decompiler IntelliJ Plugin from here: https://plugins.jetbrains.com/plugin/7100-java-decompiler-intellij-plugin
It allows you to display all the Java sources during your debugging process, even if you do not have them all

How to import source from GitHub into an Eclipse project

I am trying to use this tool from Google: https://github.com/pcj/google-options
In the example given by Google, they use:
import com.google.devtools.common.options.OptionsParser;
to allow their example code to use the command line parser.
When I do this, Eclipse says the referenced files don't exist.
I have tried putting the source file from google-options in a package in my project; no luck. I tried running Google's example, and it won't even compile. It can't find all of the classes in its own src folder.
Based on my research, I think there's either an issue with a .jar file needing to be in the build path, something to do with Apache Ant, or an issue with GitHub I don't understand.
I'm very new to GitHub; this is the first time I've tried to do anything like this.
You should first import this project from GitHub to your local machine. import statement in your class means that classes from other packages should be imported to this class you're working on. Import not from the remote source, but from local.
I figured it out. It needs the guava.jar file found here added to the buildpath. After that, it has a couple weird dependency issues with javax, but I just removed those (it was Nullable and Immutable, if anyone's interested).
First you must clone the project and compile it, to do that put the following commands:
Open your terminal and go to the workspace folder:cd {workspace}
Clone the project: git clone https://github.com/pcj/google-options.git
Compile the project: mvn clean install
Check the result, this should print: BUILD SUCCESS
In that step, maven will download all dependencies that the project needs.
To import the project: Launch eclipse, click on File /Import... choose Existing Maven project, browse your workspace where the projetc was cloned.
Create a class that extends OptionsBase and defines your #Option(s). For more information about how to use, see https://github.com/pcj/google-options#usage

Jar file too big

I created a simple project using WindowBuilder in Eclipse and my goal is to send it by email. I don't know what kind of computer the person is using, so I exported my project into a 'Runnable JAR File' and checked the option 'Extract required libraries into generated JAR'.
The problem is that the generated JAR file is 20MB in size!!! The project has only one simple window - nothing complicated or fancy.
I found that some people use ProGuard to include only what is really needed.
I would like to know if there is a way to optimize it 'manually'? Are there libraries that are automatically included when creating a WindowBuilder project, and how may I determine which libraries I can remove?
Thank you.
I've had the same Problem using WindowBuilder. My solution was to look for the imports in my .java file, e.g.: import org.eclipse.swt.SWT;
In the Project Explorer in Eclipse you can see that there are much more imports than needed. Those 'Build Paths' can be removed carefully.
Simply rightclick on a .jar import like "com.ibm.icu_52.1.0.v201404241930.jar" and click on "Build Path" and "Remove from Build Path". Unfortunately, you can't remove or delete the packages inside the .jars.
But using this method, I managed to reduce the size from 20.7MB to 3.87MB. It's something...
Like fge said, send the source. Or upload the .jar to dropbox if you require you partner to access all of the files in the .jar.
If you don't like dropbox, find some other cloud storage solutions through a google search. Github or Bitbucket could also be an alternative to dropbox.
Cheers.
Use the Eclipse plugin FatJar. FatJar shows you which libraries are getting imported and allows you to specify which .jars, libraries, etc., that you want built into your JAR.
FatJar
Your jarfile is too big due of the project template. Create a sample java project, then use windowdbuilder components. Do not create a project Swing Template, by this way eclipse is gonna import all eclipse gui toolkits.
Tried it out with my way, my application's length equals to 3Ko against 24MO with the template project

Downloaded a Java library off GitHub, do I compile it now?

I am trying to do this simple tutorial using the JARVIS Java Speech API:
https://github.com/The-Shadow/java-speech-api/wiki/Hello-World
These import lines lead me to think that I need to link to a .jar library.
import com.darkprograms.speech.microphone.Microphone;
import com.darkprograms.speech.recognizer.Recognizer;
import com.darkprograms.speech.recognizer.GoogleResponse;
But when I go to the gitHub site, the only option is to download the .java source files. How should I go about converting them into a .jar? Is that what I am supposed to do?
On that same GitHub page, you can download the jar :
https://github.com/The-Shadow/java-speech-api/releases
You should also acquire any additional jar required by Jarvis (it doesn't seem there are any from a quick look).
That said, if you want the very last version of that library (and the associated bug/problems if any), then you will need to compile it from source, ie, something like :
clone the git repositery
compile the java sources
create the jar

Categories

Resources