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.
Related
I have a java project: simple telegram bot. It worked while I didn't tried deploy it on Heroku. I did a backup for stable version, but Eclipse keeps showing me this ERROR. IDK what's wrong with it, I tried a lot of stuff, like what's the problem? I have src folder, classes also, I have main... Maybe problem in .gitignore file?
But I deleted from it *.class, it's still not working. Help
It's not a duplicate, because I'm workin in Eclipse and it worked earlier. Added my folder properties. I need short answer, not just a wiki of possible problems because it doesnt help.
Folder props
Screenshot error and folders
Your project configuration is very bizarre; you have class files in a directory named 'SRC'. It's hard to tell what you did to manage to create a project def this bizarre. Some ideas:
You've compiled this on the command line. You should probably look into build systems like maven or gradle to build your code. Even if not, use the -d switch on javac to ensure the class files end up in a directory named 'bin' or 'build'.
You've turned off eclipse's autocompile function. Turn it back on.
Right click your Point.java file (not Point.class) and pick 'run...' from the context menu. Assuming autocompile is on this will work.
Generally, use packages. Stuff in the default package is unrunnable in various scenarios. From what I can tell you're not in one of those 'default package is not runnable' scenarios but perhaps I'm missing something.
I have started to learn Java along with Eclipse and the book "Thinking in Java" by Bruce Eckel. I tried to add his util package (from net.mindview.util) to a project but Eclipse complains the name cannot be resolved.
I added an external folder net. It contains other folders atunit, simple and util which containts uncompiled *.java files. In Java Build Path -> Libraries, I have pointed at the external class folder:
but Eclipse still cannot resolve the package name:
For me, everything seems OK and the package structure is correctly organised in folders:
Just in case, I also checked whether files correctly specify package name:
I run out of options. The Eclipse help just shows how to add external folders and does not say what to do if there are problems.
Hopefully someone can help with that. Thanks.
You've got one directory too far when adding the library to the build path. The library should be showing up as TIJ4Code, in the Java directory. (Or in other words, when you choose "Add class folder" you should be choosing TIJ4Code, not net.)
That way net becomes the first part of the package name - whereas Eclipse is currently treating net as the "root" directory of the library, so it thinks that Print "should" be in a package of mindview.util for example.
I have three .class files that I'm supposed to black-box test. They are under a package named one.two.three. I'm having difficulty accessing them. I started a new java project in eclipse and created a package with the same name. I then proceeded to add the three .class files to bin/one/two/three. If I try using the classes Eclipse can't find them and I get compiler errors. I'm using the appropriate package header. Any help is greatly appreciated, thanks.
assuming bin/ is your output folder in the Eclipse project settings. Simply dropping the class files under bin/one/two/three will not work as eclipse will either delete them (on clean build) or just ignore these extra artifacts. Do as #Ray Tayek says- keep them in a different directory and edit project classpath and add this as class folder. This should work.
I'm trying to export a small program that I have made in Eclipse Indigo today to an executable, however, every time I do so one of two problems occur. The program uses one resource which I was hoping to put inside of the JAR but Eclipse will not put in the executable jar no matter which option I tick when I export or which folder the resource is in - the first problem!
The second problem is that whenever I tell eclipse to "Extract required libraries into generated JAR" I receive the following error when I double click on the executable Jar:
Could not find the main class: main.Launcher. Program will exit.
I don't suppose that the second problem is too much of an issue at the minute but the first one is extremely frustrating so I would appreciate any help or advice. Thanks in advance.
(Strangely, and even more frustrating, if I go through the same process with a project I made a while ago with a previous version of Eclipse it works perfectly.)
The folder structure of the project is as follows:
In the project folder there are the following directories .settings, bin, src as default. I have put the resource, which is a png in the bin folder but I have also tried it in the src folder.
Can you give some details?
What is the structure of your eclipse project?
Of what type is the resource?
More important where in the project structure resides the resource file?
Is the folder of that resource file included as a source folder ? (seems to be a prerequiste to get exported to the jar)
Is it copied over to the bin folder when the project is built?
Many Thanks
Michael
Update:
I have built a very simple java project 1 Java class with a main method and put a sample png file in the source folder. I refreshed the project to have the png visible in the project, then I cleaned the project to have it build again, then I ran the Main class inside eclipse. This will give you a run configuration when exporting throught the wizard. Thereafter I exported the complete project as "runnable jar", selected the run configuration and selected "Copy required libraries in a sub-folder next to the generated JAR". The png was included and the Main class was found. The executable JAR could be executed.
(Environment: Eclipse Indigo R1, Ubuntu, JDK 6)
You might want to play through the complete sequence of steps I went through. Maybe eclipse just did not pick up a file or other updates.
regards, Mike
First of all, I would like to thank Mike (marksml) for being so helpful and attempting to provide a solution for my problem. Unfortunately, his answer did not work for me!
I began to look at all of my previous projects and noticed that the one I was having trouble with was the odd one out (because it was the only one that didn't work) and the factor that made it the odd one out, I found to be the JRE system library version. The project was using the JavaSE-1.7 library but when I changed it to the JavaSE-1.6 like my other projects were using it miraculously worked and exported flawlessly! I'm still curious as to why this is the case, but at least I have it working now...
With thanks and kind regards, Andy
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"