I have been using Eclipse for 2 weeks and all programs are working fine.
But I have realized that I have not specifically installed Java SDK.
Is it normal or does Eclipse have its own compiler?
I need to test the JDBC MySQL connector and now I don't know where to copy that file because in my:
C:/programfiles/java
I have only one directory that is JRE 6.
Yes you're right. Eclipse has its own compiler so you don't need JDK if you are working with Eclipse.
There is some cases/plugins that are only working with JDK such as Maven. So if you are planning to use Maven (either from Console or from Eclipse) you will need to download JDK.
For your mysql connector, a common practice is to copy the jar to your project directory (or maybe under lib directory) and add it to the build path. Once the jar is in the location, you can refresh the workspace, right click, and select Build Path, add to Build Path.
You can download Eclipse with a bundled JRE, which is probably what you've done. But since it has its own compiler etc, it doesn't need the full JDK.
You don't need the JDK to use the mysql driver, though, you just need to add it to your project classpath in Eclipse. Some documentation suggests putting JAR files in the JRE/JDK's extensions directory, but this is a profoundly bad and outdated idea - don't do that. Use the classpath, via Eclipse's environment.
Eclipse has its own compiler and can run on a non-JDK JRE.
The usual approach to use a library jar, is to copy it into your Eclipse project inside Eclipse, and right-click-add it to the Build Path. The classes are then accessible to your own code.
Related
our company uses the Eclipse IDE with some plugins that are required to start our platform. I want to create a bundle for our Java developers that contains the latest Eclipse Java (Oxygen) with the plugins already installed.
So far I've installed Eclipse with
sudo cask brew install eclipse-java
which created an /Application/Eclipse Java.app.
After installing the plugins within Eclipse with Help->Install New Software the ~/.eclipse/ was created in my home directory.
Is there some way to zip these folders to create an distributable package of eclipse or am I missing other files/directories?
Is it possible to move the plugins in the installation directory as well?
Thanks for your help!
It is not advisable to use any Eclipse distribution that's produced by packaging tools. It's best to download directly from eclipse.org, for various reasons.
As for customizing an Eclipse "package" for distribution yourself, have a look at the Oomph project, which is designed for that exact purpose (and others). Oomph is what produces both the installer and the downloadable packages of Eclipse IDE releases. You can read specifically about Oomph authoring here.
You can use the official eclipse installer. There is an advanced mode to disable the p2 pooling. Then using this mode, everything will go into the eclipse folder. Afterwards you can zip it and give it to others. Of course you are always bound to the CPU Arch still.
I have Eclipse for Java installed on my 64-bit Windows 10. And since than, I was able to do Java development without any configuration.
Previously, the automatically build is selected by default. But when I manually delete the .class files, and want to build again, nothing happens.
When I try to run the program, it was not surprised that the error message says that it cannot find the class files.
Notice that, from the beginning, I didn't configure JDK in Eclipse, and it worked.
I found some source on stack overflow that says, Eclipse has its built-in compiler such that it does not need the javac in JDK.
Can I develop Java programs if I have only JRE installed?
But why after I deleted the .class files, the built-in compiler does not work ?
Regarding the JDK: if you are using Eclipse, then you don't need JDK because eclipse has it's own compiler. However for some plugins like Maven to work JDK will be required.
Regarding building the project: Have you tried cleaning and rebuilding the project?
Clean command is available under Project tab.
I would like to be able to use Maven to automatize the building process of my application.
The application is a runnable jar that is wrapped with a local copy of a jre using launch4j, which is then included in a NSIS script I have to build an installer.
I found a launch4j plugin for Maven that makes me able to wrap a jar with a local jre like I want to, but the thing is that I'd like to download the proper jre in a local directory when running the Maven build process.
The reason is that for compatibility reasons, the application will be using the jre 1.6 but that could change in the future.
Is there a way to make Maven download the jre corresponding to the application setting like it would download a dependency ?
Like if I change the configuration to use the 1.8 jre, Maven would download automatically the jre 1.8 in the directory I want.
Is this something possible to do or do I have to download it manually and add the jre directory to my project (or something else that I didn't think of) ?
I found a launch4j plugin for Maven that makes me able to wrap a jar
with a local jre like I want to
How did you achieve this, since launch4j doesn't wrap the jre, nor bundle/embed?
It only lets you specify a
<path>relative_jre_path_to_your_jar<path>
to a jre. You need to zip your *.exe(which results from launch4j execution) with the jre, and distribute it.
Regarding the controlling of jre versions, you can deploy jre artefacts(different versions) to your maven repository and use the dependency mechanism.
I want to know which JDK is eclipse using to compile my current projects.
Is there a way to know that from eclipse itself.
Eclipse has its own Java compiler, it does not use the JDK compiler.
The 'Preferences > Java > Compiler' preferences set which language level the Eclipse compiler uses.
You can also override this for individual projects in the 'Java Compiler' Property page for the project.
The 'JRE System Library' setting in the 'Java Build Path' properties for a project determine which JRE is used for the Java system library Jar files.
Open the project and look next to its JRE System Library folder to see the version. For example in one project mine is JDK1.7.0_51. If that does not work, then right click on the project name, select Build Path/Configure Build Path and see the configured JDK version in the window that pops up. Each project can be independently configured to use a different JDK, but one of them is the default and that can be configured in the Configure Build Path app.
I recently installed the ubuntu 12.04 final beta
After installing the oracle jdk from the webupd8 ppa, launching eclipse failed complaining about a missing shared library.
Can't load library: /home/bob/.swt/lib/linux/x86_64/libswt-gtk-3740.so
I searched around, and found this quesion: Eclipse cannot load SWT libraries
As the OP recommended, I tried switching to open-jdk, and that worked wonderfully. The problem, however, is that I am working on a project that doesn't support openjdk.
I tried the second solution as well (the one by scott, which was just creating symbolic links to /usr/lib/jni/... in ~/.swt/lib/linux/x86_64/). Eclipse launches and everything is fine, but it still misses some libraries; this is what I get when i try to run my project:
Caused by: java.lang.UnsatisfiedLinkError: /tmp/libgdx/1352105074/libjogl_awt-linux64.so: libjawt.so: cannot open shared object file: No such file or directory
I know libjawt.so is somewhere on my computer:
$ locate libjawt.so
/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/libjawt.so
/usr/lib/jvm/java-7-oracle/jre/lib/amd64/libjawt.so
But eclipse or java seems to think that libraries should be placed in ~/.swt/lib/linux/x86_64, isn't that weird?
Eclipse when launched defaults to its own internal JRE, as I understand. I recommend the following:
Modify your CLASSPATH variable to include the path to the desired libraries;
Set your JAVA_HOME to match the actual JAVA_HOME;
Setup Eclipse to launch from the desired JVM by customizing the eclipse.ini using this information: http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#eclipse.ini
Also, can you specify the -classpath option when Eclipse is launched?
Try downloading the latest version of Eclipse and running it. For some reason it works fine. I just ditched my older version of Eclipse. I hope this works for others!
Please note that there are two Java runtimes in play here. The one used to run Eclipse itself, and the one you want to run your code. They do not have to be the same!
I would suggest
Run Eclipse with a JDK that works
Download Oracle JDK manually and unzip it to a folder in your home directory
Tell Eclipse about this additional runtime (http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-add_new_jre.htm)
Configure your project to use that JVM instead. (http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-assign_default_jre.htm)
Now your own code is compiled against, and runs with Oracle Java.