Where to install the import modules used in a java program? - java

For a program the import headers are showing errors. From where can i download the importing packages? The import instance of the program is shown below..
package com.larmor.opencv.samples;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Panel;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import javax.media.Buffer;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.control.FrameGrabbingControl;
import javax.media.format.VideoFormat;
import javax.media.util.BufferToImage;
import javax.swing.JButton;
import javax.swing.JComponent;
import com.larmor.opencv.MatchTemplate;
would this all be in the java library? Even if yes pls tell me how to install packages/modules that are not in the java library..

Most of those classes are available in JSE, but it looks like it's also using JMF. You can download JMF from here:
JMF Download
You don't install modules, you just add jars/classes to the classpath. How you do that depends on if you are using an IDE or not. This article can give you some insight on how things work:
PATH and CLASSPATH

All the java.awt and javax.swing classes are part of the standard Java platform.
The javax.media classes are part of the Java Media Framework. You'd have to download and install that separately.
The MatchTemplate thing seems to come from here.
To find where a package come from, look through the Java SE API documentation or search for the package name on Google.
You need to put the relevant JAR files to your classpath while compiling and running your application which uses these classes (except if they are classes in the standard Java platform; these will be automatically available).

Related

Google Cloud Messaging Smack Library

I am attempting to implement the Google Cloud Messaging CCS server written in Java, and I have downloaded the Smack library from here. My question is, which files do I place within my project in order to use these import statement?
import java.io.IOException;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketInterceptor;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.DefaultPacketExtension;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.util.StringUtils;
import org.xmlpull.v1.XmlPullParser;
import org.jivesoftware.smack.SmackException;
You need to download the required libraries and import them into your project
I needed
Smack
JsonSimple
XmlPull 1.1.4.c
(Click for download links)
Once you've downloaded each library you need to import them into netbeans
Open your projects properties
Select Libraries
Select Add Library
Select Create
Add a name that indicates which library this is i.e Smack or JsonSimple so on
Add the jar, javadoc and sources if you downloaded them for each library
Rinse and repeat till all three libraries are added to your project

Old netbeans web app with woodstock

I am having pretty much this same issue:
JavaEE/NetBeans Library Referencing
I have done what is suggested by downloading Netbeans 6.7 and Glassfish 2, but I still don't have the libraries needed.
Here's what one of my files looks like:
import com.sun.data.provider.RowKey;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.sql.rowset.CachedRowSetXImpl;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.MessageGroup;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlSelectOneMenu;
import javax.faces.event.ValueChangeEvent;
import javax.sql.rowset.CachedRowSet;
I do not have any of the com.sun... packages and can't seem to find them anywhere.
I don't have very much experience with web apps/netbeans so any help would be appreciated. I realize that this is very outdated and should probably be migrated to something else, but for now I'd like to just make a few small edits and would rather not rewrite everything.
Thanks!
I originally had opened the project in a newer version of Netbeans that didn't have Wodostock/JSF. For some reason, it wouldn't work when opening with the older version of Netbeans. However, after deleting it and opening it again with the old version first, it worked.

Eclipse import com.sun canot be resolved in android project

I need these libraries in my android project. How can I use them?
I get import com.sun.*, java.awt.* cannot be resolved in android project
import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPage;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import javax.swing.*;
import javax.imageio.*;
import java.awt.image.*;
The classes in sun.* are not meant to be imported. They are for
internal use of the JVM only.
Use UnsupportedOperationException instead of
NotImplementedException.
Welcome to StackOverFlow, please next time search your problem before asking the question.
got the answer from here, simple search did it all.

import org.jsoup.* not working

I try to make a java app using Jsoup.
Instead of using
(A)
import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
I want to use
(B)
import org.jsoup.*;
(A) is working but (B) is not...
I am using IntelliJ and imported the dependencies...
Why is this not working ?
You should import each package like this:
import org.jsoup.*;
import org.jsoup.helper.*;
import org.jsoup.nodes.*;
import org.jsoup.select.*;
Since org.jsoup and org.jsoup.helper are different packages, you should import them separately.
In Eclipse, there is a function called Organize Import, perhaps there is similar functionality in InteliJ.

AWT libraries using Java 1.6 on Linux Server in a datacenter

I need to create and store thumbnails (of images from the web) and store them on the server. Can I use the awt libraries (as listed below) on a linux server running in a datacenter (without a monitor)? I do not know if the server has a graphics card or needs one for these libraries to work...
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.net.URL;
import javax.imageio.ImageIO;
import org.springframework.stereotype.Service;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.Color;
You can as long as you run java in headless mode:
java -Djava.awt.headless=true your.MainClass

Categories

Resources