Eclipse: I can't find Java Build Path in Project Properties - java

As the question states, I can't find the Java build path within the project properties itself
My main issue is that I keep getting "The Class file is not on the classpath" error whenever I try to open a .class file from a school project. To fix this I need to access the Java build path within project properties but it is not showing up for me. I'm not sure how to fix this.

I don't have Mac, but i guess You should try this if you haven't done it yet.
File-Import-Existing_project into the workspace. Browse to the location where the .classpath and .project files locates in your project.
Then check your environment variables (google can help with this) and classpath variables:
Window - Preferences - Java - Build Path - Classpath Variables.

The project seems like is a general project (No java project), so it's normal that 'Java build' option is missed.
Besides, you can't open .class files, because is a Java compiled file by the Java compiler. You must search for .java files.

Related

Adding .dll to java build path

I'm using a .jar library that needs additional .dll or .so to function.
I copied them in a folder in my eclipse project and then added that folder to the native library location in Properties -> Java Build Path -> Libraries. When I start my application in eclipse, it works well but when I export it as a runnable jar and then execute it, it doesnt work anymore and gives me a java.lang.UnsatisfiedLinkError error.
Is there a possibility to add these additional files inside the .jar and also add them to the java.library.path variable when running the application?
Regards
I would suggest creating new resources folder in Eclipse (if you are using it, since that folder will be on classpath), or just add it manually to classpath.

Eclipse configuration to run a JNI project

I have a project that uses a few jar files which happen to be JNI wrappers calling some DLL libs. I included those jars in the classpath and specified the native library location for them from within Eclipse (java build path->Libraries), as suggested by some posts in this forum.
However I still received error like:
C:\projects\java_workspace\lib\\xyz.dll: Can't find dependent libraries
Some interesting facts:
1. If I set %CLASSPATH% for jar files and %PATH% for DLL path as env variables and run the program from command console, it works like a charm;
2. I used Dependency Walker to check the xyz.dll in question, even though I can find the dependent dll files in the expanded tree under xyz.dll, from the list box at the bottom I did notice there were two dll files that Dependency Walker complains "Error opening file, the system cannot find the file specified".
Anyone can help config the Eclipse env so I can run the program from within the IDE? Or any comments?
Thanks!
John
Did you try setting the PATH environment variable in the 'run configuration'? (Right-click on the java file containing your main, then 'run as', then select 'run configuration'.)

Java classpath - one jar accessible, other not. Why?

I'm trying to include a weka-src.jar file in Netbeans project and use it.
I already have set up my CLASSPATH and included :
C:\Program Files\Java\jre6\lib\ext\weka-src.jar into it
My JAVA_HOME variable is set to:
C:\Program Files\Java\jdk1.6.0_25\bin
but still I get the error in Netbeans: package doesn't exist and NetBeans doesn't auto-complete when I'm trying to add it to imports
Similar to this I jave a jar file
C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.0.8-bin.jar
also included in CLASSPATH and after adding to project Netbeans does the auto-complete thing.
My cmd:
echo %CLASSPATH%:
.;C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.0.8-bin.jar;C:\Program Files\Java\jre6\lib\ext\weka-src.jar
Tried in Eclipse, the import part is not underlined, but still I can't use the classes, as if weka-src.jar wasn't even added
I can't figure out what is wrong. Any hints, please?
Maybe there is someone who can test it in his environment? weka-src.jar is in Weka's program files folder.
I am guessing that weka-src.jar contains source code which need to be compiled before it can be used. Perhaps there is a weka.jar which has the compiled classes in it.
In netbeans, you don't make classpath with windows environments variables, but with netbeans.
In netbeans right clic on your project node in window projects, choose Properties, and in properties Librairies. Add your jar.project/librairies with that.
Istao is correct. For NB you need to add jars via Properties

Java eclipse directory structure and tomcat

I have a java application hosted on tomcat, which has a directory structure like :
webapps/my_aapp/WEB-INF/CLASSES/SERVLETS/xyz.java
webapps/my_aapp/WEB-INF/CLASSES/SERVLETS/xyz.class
so that's how classes are referenced .
Now (I am new to eclipse), it generates a different directory strucutre, in which all .java files are outside the code and I don't know where class files are stored.
The result is that when I upload the files, and compile, I get errors like this:
javac -Xlint servlets/Ajax.java
warning: [path] bad path element "/usr/java/jdbc7.2dev-1.2.jar": no
such file or directory
warning: [path] bad path element
"/usr/java/mysql-connector-java-3.0.16-ga-bin.jar": no such
What's the best way to understand this java directory path issue? Better yet, how to synchronize this structure?
I want to keep my eclipse directory structure on tomcat.
Typically eclipse stores all class files under bin directory located under your project near src directory.
I personally like name classes more than bin, so I always change it when I am creating project or later using project properties (right click on project -> properties -> build class path.)
Check your disk, I believe your class files are there. Unless you are using some pluging that can change this behavior.
What kind of project are you using in eclipse? A WEB project? An ANT-build project? MAVEN build? The way it builds classes depends on it. There is not much that I can help you. Because you do not provide enough detailed information with your question, but I will try.
Anyway, you can configure your output dir to be web/WEB-INF/classes (which is not statndard and not recommended, but I am doing it in one old project ;D) if you have it configured as java project.
1. Right click on project,
2. Go to Java Build Path
3. go to source tab, select source folders and select output folder (in my project mypoject/web/WEB-INF/classes ).
4. If you want to run and debug on apache tomcat from withint eclipse using this configuration, you can use eclipse sysdeo tomcat plugin.
Other thing is: You have specified absolute links to libraries (I suppose looking at your error messages), please copy them to web/WEB-INF/lib and change links in project settings. (If you are using maven that you should learn maven, if you are using ant, than just rewrite the part thaht uses these libs). And check if you already has this libs in tomcat/shared or tomcat/lib classes.
Another way is to learn to work with standard way of creating web-projects in eclipse, and add a build and package tasks to your build process (whatever it is make, ant or maven). Then you should deploy your PACKAGED application (let it be *.jar).
My suggestion, please, read "Head First Servlets & JSP by Kathy Sierra, Bert Bates, Bryan Basham" this is great book. It has everything you should know about HTTP, JSP, servlets, tomcat, and web-application directory structure. It will make things much easier for you (at least it worked for me, it really helped me much to understand things, and it is great fun to read).

Getting started with Java using Eclipse

I just heard of library for reading/writing excel files without COM, so I figured I'd go check it out.
I downloaded jexcelapi_2_6_12.zip from this page http://sourceforge.net/projects/jexcelapi/files/ but I have no idea how to open it in Eclipse.
I know it's a silly question, but I'm sure it's not the first time someone's asked it, how do I open this in Eclipse in Windows, compile, run and debug it?
Primarily what you need from that zip is the jar which contains the library. You'll still need to actually write a Java app that uses it.
So what you need to do is:
Unzip the file you downloaded
create a new java project
add a lib directory to the project
copy jxl.jar from the zip into your projects lib directory
right click on the jar in eclipse and select "Build Path>Add to build path"
The classes in the library are now available to your project
Next create a new java file in your projects source folder and start coding.
Extract the zip file somewhere, put the jar file in your project's directory somewhere (e.g. under a lib directory) and then right-click on it and select "Add to build path" or something similar.
It's not runnable on its own though - you'll need to write some code in order to debug.
If you want to debug into the source code of the library itself, you'll need to tell Eclipse where the source is - but that's unlikely to be necessary.

Categories