First, sorry if question is trivial - I'm new to java world.
So, I've created new project. Then I downloaded websocket jar file here:
http://www.java2s.com/Code/Jar/j/Downloadjavawebsocket130jar.htm
After that I've created 'lib' dir, copyed jar file there, selected it, added to build path.
Basically, I was following instructions from here:
http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29
Then I copied source code into my class:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Collection;
import org.java_websocket.WebSocket;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
So, first part of imports is ok...standard Java imports. But problem is second group. For every import, starting from:
import org.java_websocket.WebSocket;
I'm getting error "Import.... can not be resolved." And rest of the code that's using those classes is shooting errors because of that of course.
So, I added jar file to build path, but I still can't import classes from that library. What's missing here?
First, extract the jar from the zip file, then right click the folder you're working on in your Eclipse. Click "Build path", then click "Configure Build Path", then click on "Libraries" and on the right hand side click on "Add external Jars", and then find your extracted jar.
Download the bundle from the below repository.
MVN Repository
This should resolve your issues.
Related
FYI, I'm new to Java development and Netbeans!
I have downloaded the MigLayout jar files, both core and for swing, and added their path in the NetBeans 8.2 IDE under 'Tools->Libraries->Library_Classpath'.
My problem is that I'm trying to use the API MigLayout() but every package name that I've tried to import it results in the error "package 'Package_Name' does not exist"
The following package names fail at compile time:
import MigLayout;
import net.miginfocom.MigLayout;
import net.miginfocom.swing.MigLayout;
The following package names only fail at run time:
import net.miginfocom.layout.Grid;
import net.miginfocom.swing;
import net.miginfocom.miglayout;
Links to the MigLayout forum are broken, and none of the tutorials I've seen have the import statements. All I am asking for is a link to or list of the packages needed to use MigLayout.
If MigLayout is no longer supported, it would be nice to know that as well!
Of all packages you mentioned, the following are actually working:
import net.miginfocom.swing.MigLayout;
import net.miginfocom.layout.Grid;
It is not enough to set the jar files in the library configuration of NetBeans (Tools > Libraries). You also need to set it inside your project to get your classpath working.
In the projects view, locate the directory called Libraries (JDK will be located there) and right click on it, then click on Add Library and choose the library where you defined your jar files, in your case Library_Classpath.
I'm beginner with Java/Android and Parse. Today i need your help . I don't know what i'm doing wrong. Look to my picture
My .jar file is in "Lib" , but i'm receiving the red lines in my project.
Also ,how can you see in Parse.initialize seems that this is not recognized.
you should import classes
add this import statement to your codes
import com.parse.Parse;
and import every class you need
you can also import all classes
import com.parse.blablabla.....;
and if you have added .jar files you can fix imports in android studio .check this one
follow these steps
1) add parse libs to your project.
2)clean your project
3) add import statement
import com.parse.Parse;
you can see i have no error after i did those steps
this is my project no errors
Hi I am writing a test using UIAutomator API , however in my java project I want to import the com.android.camera package.
However I am always getting an error that this import cannot be resolved.
I have added the android.jar in my build path and rest of the things work fine.
However I am not able to import this package.
There is no such package in android, maybe you are looking for
com.android.hardware.Camera
class ?
if so try
import com.android.hardware.Camera;
The camera class resides inside the below package so try to import below package instead of com.android.camera add the below.
import android.hardware.Camera;
import android.hardware.Camera;
try to place it after your package name
If you are using Eclipse than just press Ctrl + Shift + O Eclipse will automatically add the required libraries in your source code. If still you are getting import issue than you need to check if you are using correct API or the spelling is correct.
I'm porting some java code into GRAILS framework and I keep getting this error when importing libraries (jcraft):
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.ChannelSftp.LsEntry;
MyServiceImpl.java:47: package com.jcraft.jsch does not exist
[groovyc] import com.jcraft.jsch.*;
[groovyc] ^
I've tried adding this to 'BuildConfig.groovy', but still same error.
dependencies {
compile 'com.jcraft:jsch:0.1.43'
Any idea what I need to add? I also added the actual jar file in the Build path library. Many thanks.
have you tried to copy this library into the lib folder of the grails-app structure and removed all refernces from e.g. BuildConfig.groovy ...
i can also try to unpack the library and check if the lib-structure is correct.
What do I need to do to successfully the import ij package? I get an error:
ITCN_.java:1: package ij does not exist
The imports are:
import ij.*;
import ij.io.*;
import ij.gui.*;
import ij.process.*;
import ij.measure.*;
import ij.plugin.*;
import ij.plugin.frame.*;
import ij.plugin.filter.PlugInFilter;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
import java.text.*;
I also used Jgrasp back in the day.
I highly recommend moving to eclipse although jGrasp is very simple and works.
To Add to the Build Path you go to Settings -> PATH/CLASSPATH -> Workspace
Click on the "Path" tab, and then the "CLASSPATHS" subtab.
Then Click "New" and where it says Path or Jar file, enter in the path to the ij jar file. Do this for each file if there are more than one.
And then click "apply" and you should be able to use import ij.* and the subsequent functions
It's the ImageJ API. The API docs are available here. You can download it here. Once downloaded, just add the JAR(s) to the compiletime and runtime classpath.