Trouble importing libraries from Processing into Eclipse - java

I had a problem loading sound using the sound.processing library, so I am trying to use the ddf.minim library.
My Instructor imported the sound.processing library into processing AND Eclipse, and I don't remember how he did it. I tried going into processing and downloading minim from the sketch
When I try to import ddf.minim into my project, I get a red line under ddf. I also manually downloaded ddf.minim from github, removed the one previously installed, and I believe I had replaced it with the github files. I then went to add libraries in processing, and I still can't even import ddf.minim in Processing, let alone Eclipse!
Please help, I am just trying to get my sound to work in my Java project!

You need to add the Processing library and the Minim library to your classpath.
In Eclipse, to set your project’s classpath, right-click your project, and then click the Properties option. This brings up a dialog with all the settings you can specify for your project. Click the Java Build Path menu, and then the Libraries tab, which takes you to this screen:
This is your project’s classpath, and any library jars you want to use should be added here. Click the Add External JARs... button and select the .jar files that come with Processing. For basic sketches, I believe you only need the core.jar file.
Then for Minim, you can download the library .zip file from here. Unzip that wherever you want, and it should contain the .jar files that you need to add to your classpath.
Shameless self-promotion: here is a tutorial on using Processing as a Java library, and here is a tutorial on using Eclipse.

Related

How do I add LWJGL 3.1.1 to netbeans to use in a Java project?

I want to use the Light Weight Java Gaming Library(LWJGL) to my Netbeans so I can use it in my Java application. The only videos that I can find show the zip file that they downloaded with separate src and doc folders inside of it. The zip file that I download has everything in one directory. I went to lwjgl.org/download and clicked on Stable and then Generate Bundle. What am I missing?
I had the same problem recently.
So, to begin you want to go to Tools in the context menu and select Libraries (as shown). Next you can add a new library and name it e.g. LWJGL-3.1.1 confirm with ok. You can find 3 tabs in the current window Classpath, Sources and Javadoc. There you add your jar files accordingly (in the downloaded .zip file you find .jar files with different names like lwjgl-{whatever}-sources.jar or lwjgl-{whatever}-javadocs.jar) make sure you put them in the right place. You have to repeat this process for all of the jar files you want. The javadoc files are not required but recommended. Make sure you also collect all the native .dll files and merge them in a folder called \natives. You find them in these jar files that are called like: lwjgl-{whatever}-{your-OS}.jar.
Once you have finished the setup for your library right click on your current project and choose Add Library.... In the window that pops up you scroll down until you find your library that you have just created and you are almost done now.
Last but not least go to the project settings. Select Run and make sure that you set the classpath in VM options to something like in the image: -Djava.library.path="C:\java_workspace\LWJGL Library 3.1\natives. Now this classpath tells netbeans where your native files are located. Your \natives folder that you should have created in the beginning is where this path should lead to. That's it. This is all you have to do for a setup without the use of maven, gradle, ...
You can test if it is working with the code provided by LWJGL HelloWorld example.
I hope this solved your problem.
Best regards.

Referencing .jar files in NetBeans

I am trying to use FEST automation software. I am currently dealing with NetBeans 6.8 because it is what I have to use at work and am unable to upgrade the software at this time because of our system requirements
[TLDR: don't tell me to upgrade NetBeans because I can't]
I have downloaded the jar files from the google code repository and am trying to get a very simple application to work. I have tried adding the jar files to Libraries through the property panel for my project. NetBeans still cannot find these methods. Where else/how do I add these jar files to the class paths?
In order to use .jar files in NetBeans, you can either add the jar file to your global libraries or your local libraries. It sounds like you tried doing it locally without much success. I recommend adding a library such that you can just pick from your list of libraries without needing to reload it. I use NetBeans 8.1 so it may be just a bit different for 6.8.
What you need to do is go to Tools->Library
Then you need to click on New Library at the bottom left of the dialogue box.
AddLibrary
Name it and hit 'Ok'. Then, you'll add a new jar file by specifying your jar path. Hit 'Ok' again to save everything.
In order to use your new library, you'll need to then click on your Libraries folder in your project and add a new library. Select from the list of libraries the library you just created.
SelectLibrary
Finally, you import your individual files in your library using the #import keyword as per usual. If you want to import everything, you'd type something akin to
import MyNewLibrary.*;
To load a library the way you tried to do it, you'd right click the libraries folder and click "Add JAR/folder" instead of "Add Library". Then you'd import everything.
If you still for some reason cannot get your library to work, then you probably aren't importing using the right name. Or, you might be trying to load a static library without using the static keyword.

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

PrintCommandListener is missing

I'm trying to upload a file via FTP client using Java, but when trying the:
import org.apache.commons.net.PrintCommandListener;
the PrintCommandListener is show in red. I verified my library and it does include commons.net. What should I do?
PrintCommandListener is in fact in Apache Commons Net. For example, if you download the current version, the jar you need to include in your build path is commons-net-3.3.jar. If this single jar is seen by your compiler, then the class should be recognized. Make sure there are no other classes called PrintCommandListener (for example custom ones that you might have written) in your build path.
If using an IDE (such as eclipse) make sure the jar is on your build path. For example, with Eclipse right click project, go to Java Build Path and click Add JARs. Navigate to the location of your jar file and add it.

How to add a library to an android project?

I have downloaded a messaging framework library from eneter.net. In eclipse I have imported the library to the /libs folder. I right clicked on the library and then added it to the build path. I know that the code is right, but when I compile it and try to run it, it says that that it can't find the classes. Odd thing is when I open up the apk in a zipping program, the library wasn't added to the apk at compile time. Does anyone know why this would be?
Try right-clicking your project in Eclipse's project explorer, then hit Properties. Go to the tab labeled Java Build Path and hit Add Library... (or if it is a jar file, Add JARs... if you already added the Jar to your project and Add External JARs... if it is not yet within the project). From there, browse for the library you wish to add and add it to the project. Re-compile (maybe even Project->Clean) and try running it, and see if the library gets added now.
I right clicked on the library and then added it to the build path
That is not necessary, as of the R17 version of the ADT plugin in Eclipse. Moreover, it may cause problems if you do it.
Does anyone know why this would be?
Possibly because there is a typo in your directory name, such that it is not named libs/. By adding it manually to your build path, you are compiling against it, but the build tools are not adding it to the APK.
Is the library in the form of a complete Android project? This is then used with another Android project by going to the Properties of that project, selecting the Android tab, and then finding and selecting that library in the lower window.

Categories

Resources