Where to put downloaded java package? - java

I downloaded a javax speech class. I cant seem to import it in eclipse. It doesnt recognize it as an import. I think it is becasue i havent put the package in the right place. Where should i put it?

add the class/jar in your classpath
right click on your project --> java build path

Related

Cannot get JavaFX to work in Eclipse

I'm trying to use JavaFX in Eclipse but whenever I use any of it's Classes it doesn't recognize the type. To clarify I get the message "Dropshadow cannot be resolved to a type"
This happens not only with Dropshadow, but with any of the JavaFX classes. The IDE won't give me an option to import it and when I try and to type it in manually it isn't recognized. In using JSE 8u25, which apparently has it included.
In looking around I see that the .jar file can be added manually, but I would like to know if something within my IDE isn't configured right, because it should be working. Can anybody give me a hand with this? Thanks.
So I finally got it working, the solution was to install the eclipse plugin found here:
http://www.eclipse.org/efxclipse/install.html
The directions are pretty good, I just followed them as written and got it up and running.
Adding to Build Path
Your problem here, is that you just dropped your .jar file right in there, and tried using it. You need to add it to the project. To do so, follow the below steps:
Add the .jar file to your project folder (not src) via. copy/paste or simply drag/drop.
Right click on the .jar file once it's inside your project.
Press Build Path > Add To Build Path
What you have/will done, is adding the .jar to the project itself. Theres a difference between having it in your project, and having it a part of your project.
Now you can import, extend, implement, whatever you need.
Removing from Build Path
Ok, so you found a better library for what you want, no longer need the library or made your own, and you want to delete your .jar.
Well, firstly, it's still a part of your project, so you need to remove it from the Build Path first.
Right click on the .jar file.
Press Build Path > Remove from Build Path
Your .jar is still inside your project, but no longer a part of it.
Now you may go ahead and delete it without worry.
The simple way to solve your issue is to right click your project, go to properties > java build path then select the tab where it says Libraries.
You have to select that library you have in there > click the button EDIT then select from there Workspace default JRE . You need to have at least java 8.

Importing JSON into an Netbeans project

I need to import JSON library into netbeans.
How can I do that?
I searched on internet and I found this article.
According to this article when I import
import org.json.simple.JSONArray;
import org.json.simple.JSONObject
that, it must be work. But unfortunately it didn't work. and I get an error:
Package doesnt exist
Thanks for your help.
As the article says you need to add the simple-json library to your project:
http://code.google.com/p/json-simple/
For this we have to add Class org.json.JSONObject which available in json-20131018.jar.
We need to download this jar and add this jar to your buildpath.
for it in netbeans right click 'libraries' in the project list, then click add jar/folder.
Download jar from here : https://code.google.com/archive/p/json-simple/downloads
And then add it to your "libraries" in netbeans.
Added this answer, because other answer didn't provide the above link, which is the easiest to download jar from.
try add json-20131018.jar. This solved my problem.
http://mvnrepository.com/artifact/org.json/json/20131018
Or, instead of relying on the old version which uses the old import, use the newer version with the new import:
import com.github.cliftonlabs.json_simple.*;
For Netbeans, you can right click the project and go into Libraries to make sure the jar file is added into Classpath (not Modulepath). Press the '+' button to add it under that section by either by using a created library with the build jar and javadoc jar or, more simply, just adding the single jar file (json-simple-3.1.1.jar) directly to the classpath.
After doing this, the jar file should show up in the 'Libraries' folder under the project.

package org.python.util does not exist

another problem. I have already placed my Jython.jar into what my computer recognizes as the Java CLASSPATH. This done, importing anything from Org.Python is not found by the compiler! Do I need to have the Jar in the same folder as the java code as well?
Thanks to anyone who replies :D
---------------------------------------------UPDATE-------------------------------------------
Still not working
within CLASSPATH I have Jython.jar.
within the location of my code and batch-compiler, I have the jar.
and I have typed "import org.python.util.*;" and nothing else are the beginning of my code
and it is still giving me errors :C
Make sure that you spelled the package correctly! In java the convention is to have packages with small letters: org.python
If you are using command line to compile and run your code then you will need to add the folder containing the given Jyhton.jar file.
For more help take a look at: http://docs.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html
If you are using an IDE:
Eclipse:
Got the Properties/Java Build Path/Libraries. From there you can add external Jars.
Netbeans:
Go to the projects Properties/Libraries/Compile tab and add all the JARs that you want to be included.

Package does not exist when importing JAR file

I have a JAR file that contains a series of .java files/stub code. I need to include the JAR into a NetBeans project and call the various methods contained within. I've attempted Solaris as well, but no luck there either.
At the moment, the entirety of my Main.java (the only src file in the project) is:
package TestApplication;
import edu.university.department.ws.DiscoveryServices;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
The exact error is:
C:\code\Projects\WebServiceTest\TestApplication\src\testapplication\Main.java:3: package edu.university.department.ws does not exist
import edu.university.department.ws.DiscoveryServices;
1 error
I added the JAR file by going to libraries, clicking Add JAR/Folder, and selecting the JAR. Once it was added, I can drill down into it in NetBeans and see all the stub code, including edu.university.department.ws.DiscoveryServices.java, but yet it can't seem to import it.
I also tried going to Tools -> Libraries then adding the JAR to the classpath there. It didn't change anything.
Is it possible the JAR file wasn't created correctly? I can see the code in NetBeans, so I don't think anything is wrong with the JAR, but I'm new at this and not sure what I should be looking for.
Thanks!
Try this:
http://gpraveenkumar.wordpress.com/2009/06/17/abc-to-import-a-jar-file-in-netbeans-6-5/
Hope help.
Does your Jar really contain .java files? It looks unusual, because java-files should be compiled to .class files before packing to Jar.
Maybe http://docs.oracle.com/javase/tutorial/deployment/jar/ can help you.
Haven't you seen some warnings while installing the jar?
I have seen that message when I had erroneously the same jar installed twice - as compile library and as a test library.
As the result, many of packages became invisible.
After removing the jar from compile libraries everything become visible.
One can understand, why the such a problem may comes from.
I have had this problem, when used in Netbeans IDE the java SOURCE code using
pasting code from the other internet source by Ctrl-C Ctrl-V key combination.
(Pasting from other IDE).
The reserching of prombled showed that the problem is of absence of
statement "package nameofpackage" in code, that you want to use as library.
So, to correct the mistake you need to insert the statement package in project you want to use as library.
Perhaps, you need also to delete and link library in Netbeans again.
To link library I used the the menu point "Add library as JAR file" from tree menu item in project "Libraries" and rignt-mouse click - then "add library"

NetBeans error: package org does not exist

I just installed Netbeans IDE. I am now unable to import any org.* libs and it just says package org does not exist.
Also, I imported jdic.jar into the project and even though the code completion suggestions show up as org.jdesktop.*, it shows the same error.
How do I fix this?
Clearing the cache fixed it.
In windows 7 the cache is located in
C:\Users\username\AppData\Local\NetBeans\...
On Linux, the cache is at:
/home/username/.cache/netbeans/...
On clearing the cache, and restarting netbeans, it started to recognize org.* imports again.
I did it easily, just click the Jframe, on Navigator tab, right-click -> Set Layout -> Absolute Layout and YEP, It works for me.
org.netbeans.lib.awtextra is part of the AbsoluteLayout library. It should be added automatically by the ide whenever absolutelayout is used in the form. But if you switch to some other layout after using absolute layout, then the jar/library will be removed from the classpath and existing code making calls to the library will not compile.
If you would like to use absolute layout, then please include the library in the project. Select 'Libraries' node in the project, right-click and select 'Add Library' and select 'Absolute Layout' library from the list of available libraries.
If you do not wish to use absolute layout, then it is best to uncomment/remove code relying on the library and re-do the form design using the new layout.
Can you try importing
import org.xml.sax.Attributes;
This is part of the JDK. If you can't find that, something is really wrong.
I suspect you need to add the libraries to your maven pom.xml file.
You should redirect all the lost .jar files by exiting netbeans, then reopening it. There should be a prompt asking you to help the IDE find the .jar files. So please do so. If you aren't able to find the jar file. Clean and build the individual packages. There a new directory called a dist directory will be created in the package directory. Now you can redirect them.
Above was not working for me so I tried below and its working:
Google "absolutelayout.jar download"
Download jar
Open NetBeans and Add this "AbsoluteLayout-RELEASE***.jar" file to your project Library folder.
now try to run the project/file
in my experience the problem was with a Jpanel with AbsoluteLayout, I put free-design and solved the problem

Categories

Resources