I have an old Java 6 Project in Eclipse. To use functionality of Java 7 I would like to switch to Java 7. I am not able to do it :
Goal->No compilation errors in my Java Code . See red underlinded the compilation error when using ZipFile with 2 parameters used for Java 7. The Constructor of ZipFile in Java 6 has one argument. In Java 7 there are 2 arguments:
My Environment in my project:
Compilation Error is:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor ZipFile(String, Charset) is undefined
The constructor ZipFile(String, Charset) is undefined
at ZipCompare.compare(ZipCompare.java:103)
at ZipCompare.main(ZipCompare.java:77)
When I create a new Project from scratch, there are no compilation errors. I compared all settings from my old project and the new one and did not find any differences so far ?
Any help ?
Here are the exact steps in case anyone in the future needs them:
In the Package Explorer window, right-click your project and select "Properties" from the context menu, or go to File > Properties.
In the Properties dialog window, select "Java Build Path" from the left sidebar menu, then click the Libraries tab on the right-hand side.
Select your 'JRE System Library' and click the "Edit..." button. Assuming you have the latest JRE installed, you should be able to change the "Execution environment" there.
If not, go to "Alternate JRE:" and click the "Installed JREs..." button.
Assuming you don't see the one you want listed, click "Add...", ensure "Standard VM" is selected, click "Next", click "Directory" and navigate to your new JRE root folder (i.e., "C:\Program Files\Java\jre1.8.0_20").
Once you click "Finish" and then "OK", you should be able to switch back to "Execution environment" and select the JRE you desire.
Click "Finish" and then select "Java Compiler" from the left sidebar menu. Double check that under JDK Compliance you have "Use compliance from execution environment...." checked.
Now your project should compile and run under the new JDK/JRE.
My messy solution. I don't know if there are sideeffects. So far no:
Rename the old project to XXXXX_OLD
Create new Project XXXXX with initial JAVA7 Environment
Close Eclipse
Copy Content of Folder XXXXX_OLD to XXXXX
Start Eclipse. No Compilation Error anymore for my Constructor ZipFile(1,2)
I would really like to know the right way. I only gave this solution for probably help other peoples with the same issue. Use this Method on your own RISK! Its messy.
Related
I recently installed the Java 1.8 Update 20 JRE on my Mac running OSX 10.9.4. After that, I also added the JDK of 1.8.0_20. When I go into Terminal and execute "java -version" or "javac -version", each time I get "1.8.0_20" as a result. For me, this means that both JRE and JDK 1.8 are the System standard right now (I might be wrong on this).
So, I also add IntelliJ IDEA 13.1 and open it. I logged into GitHub using my credentials and it worked. So from the launcher window, I proceed Configure → Project Defaults → Project Structure. From here I firstly click the "New" button next to "No SDK" and select JDK. It automatically brings me to /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home. Just to make sure I select the JDK itself, I back off into ~/JavaVirtualMachines/ and select the jdk1.8.0_20.jdk, hitting return. This is now recognized as "1.8" in IntelliJ.
On the left hand side, I now go to Libraries and hit the "+" sign. This also automatically brings me to /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib. I know that it has to add all the .jar files in this folder, so I highlight using SHIFT + CLICK the entire contents of the folder and click "Ok". This is now library "ext" (don't know where that name comes from). I click Apply and Ok and go back to the Quick Start menu.
Selecting "Create New Project", I leave the template for Java and see that the Project SDK has been set as 1.8 (Java version "1.8.0_20"). Underneath it gives me the option to tick for "Groovy" (again, no idea what that is) and lastly, the library... Only that the line "Use library:" returns "[No library specified]". Even when I tick Groovy and the library field becomes clickable, it still does not find the before-created Java library. Nevermind that, I untick Groovy and go to write some simple Java code: Under the project name, in its src folder, I create a class and write:
public class main {
public static void main (String[] args){
System.out.println("Hello World!");
}
}
When I try to run the code, the button for it is greyed out. I have been searching the SO forum for a while, but it doesn't seem that anyone on JDK8 and IntelliJ 13 had this exact problem. Any ideas?
Okay, I figured this out: Removed JDK 1.8 with its JRE for purpose of a clean install down the line.
Went into Eclipse and tried to run the same code with no trouble. So I opened IDEA and removed the JDK and lib that I added manually. Then, I inserted back the 1.7 JDK and left it as such. Opened a black project and did not tick Groovy or the library option. For some reason, IDEA now reads the JDK internal Lib and includes it in the project. Created a new "main" class and wrote the same code as above. Then I checked the run options and although 1 was greyed out, the other worked.
From then on I installed JDK 1.8 again and tried the same, everything works just fine now.
So i'm a student in high school new to the Java language and i'm using this program called jgrasp, which we use to program java. I just got the program for home to try to finish off a lab I was working on and when I compile, this shows up:
----jGRASP exec: javac -g EqualToThree.java
----jGRASP wedge2 error: command "javac" not found.
---- This command must be in the current working directory or
---- on the current system PATH or jGRASP PATH to use this function.
---- System + jGRASP PATH is "C:\Program Files\Java;C:\WINDOWS\system32;C:\WINDOWS\system32\wbem;C:\Program Files\QuickTime\QTSystem;C:\Documents and Settings\Andrew\My Documents\Downloads;C:\WINDOWS\system32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\".
---- Use Settings > PATH/CLASSPATH > Workspace (PATHS tab)
---- to add directories to the jGRASP PATH.
----jGRASP: operation complete.
I just recently upgraded my java to the latest version, and I honestly have no idea how to fix this. I did go to the class path, and selected the selected files it wants, but still no luck. Any idea?
I had a similar problem, I do not know if it is specific to windows 7 or what.
I had installed several copies of the JDK thinking that would automatically fix it. It did not. Jgrasp somehow had multiple paths to the Java Compiler (javac), and the first one it went to was the JRE.
I solved it this way:
I went to SETTINGS/ PATH/CLASSPATH / PATH(tab) / PATH(tab)
click New
(in a seperate windows explorer window I verified the correct path to the JDK)
and added
C:\Program Files\Java\jdk1.8.0_11\bin
click Apply
click Ok
That fixed it, and made the bad frustration go away.
I'm with the same problem and then found the jGRASP install documentation. It suggest the following:
Go to the Settings > CLASS/CLASSPATH > Workspace
Select the CLASSPATH tab, if is not already selected, then click 'New'
In the dialog, click the Browse button for 'PATH or JAR file' and navigate to the JAR file or the folder containing the target Java package root, and click the Choose button.
I found all that in the documentation: https://www.jgrasp.org/tutorials187/01_Installing.pdf
Specified VM install not found: type Standard VM, name jre7
Have you ever encountered this problem in Eclipse while building an ant file? Then this article is for you. Deleting and recreating the workspace is not the solution. There is an easy solution to fix this issue without recreating the workspace.
Right Click on build.xml
Go to "Run As" >> "External Tools Configurations..."
It shall open new window
Go to JRE tab
Select proper JRE if missing (sometimes jre tabs shows error mark on that.)
For more technical details or issue similar to this find my blog here.
In my case it happen as I have changed my JRE.
Solution :
Right click on your ant script > Run as > External tool configurations... > Go to JRE tab > select JRE
Hope this help.
Thanks,
Sagar Vyas
Best answer found at
It happened for me after Un-installing Java and installing new version.
All I have to do is in eclipse open Installed JREs from
Windows --> Preferences --> Java --> Installed JREs
Then Add new JRE information. Details can be found here
This is a preferred way tell projects which JDK container to use, especially true if two or more devs are using the same version controlled eclipse project folder.
Window/Preferences/Java/Installed JREs
List one or more JDKs installed on your computer. Eclipse defaults name to jdk1.X.X_XX you should keep it as is. Never link project build settings directly to use these names.
Window/Preferences/Java/Installed JREs/Execution Environments
List of common jvm environments such as JavaSE-1.6 and JavaSE-1-7 names. Click rows and choose jre instance on the right side panel. These names are common and all team members should already have them in Eclipse installation.
Step 1: This is where you may accidentally have nothing chosen if JREs were uninstalled or names changed in InstalledJREs setting. You may get
Specified vm install not found error dialog.
Step 2: Choose 2nd mouse on build.xml file/Run As/Ant Build... popup menu entry. Click on JRE tab and choose execution environment. This may have obsolete value from the previous jdk values.
Project Properties/Java Build Path/Libraries
Add Library.../JRE System Library/(x)Execution environment
Choose execution environment to be used for this project. Team members may not have exact _XX jdk build but they can use the same version controlled eclipse project settings. Execution environment mapping hides user specific details.
Just had this issue & the solution above does not work, atleast not for me.
Instead I went the solution provided here:http://www.javaworkspace.com/VMNotFound.do
Essentially you go to the directory C:\projects\WORKSPACE.metadata.plugins\org.eclipse.debug.core.launches
In there search for the string of the JDK that that eclipse is moaining about & change it to the name of your installed JDK that you want to use that eclipse knows about.
You can change what JRE the ant bulid file is launched with inside eclipse.
Right click on the ant file in the ant view and select "Run As"->"Ant..." from the context menu.
Then in the launch dialog select the JRE tab. Note the error message at the top if it can't find the JRE that it expects.
Select a JRE that you have installed or manage install a new one. You can also add vm arguments (enable logging or change memory alocation) if you need to in this dialog.
Just delete the below file
"<Your eclipse workspace location>\.metadata\.plugins\org.eclipse.debug.core\.launches\<projectname>.xml.launch"
link to post
The last answer is absolutely correct, however a fast track way is to delete the project reference from eclipse (make sure to keep unchecked delete source) and import your project folder again. This way the project configurations are reset by eclipse using the new jdk.
But a wonderful post it did help me.
After Java update ant build failed and the below steps fixed it .
Right Click on build.xml-Run As-External Tools
Go to JRE tab and check the box to use the JRE same as workspace.
Removed below file and build maven project again, worked for me.
.metadata.plugins\org.eclipse.debug.core.launches\.xml.launch"
(ant file)Run As--> External Tool Configuations,
go to JRE tab and choose JRE
First i installed java 7.0 update 25 and then installed eclipse.
Later as per requirement, I uninstalled this java version and installed earlier version 5.0
Now in every eclipse program, it is showing error with word 'System'.
Solution is to add path of java.exe to eclipse.
Can anyone guide me to do it?
To resolve this problem perform below steps:
Go to Package Explorer -> Select your Project -> Right click on your project -> go to Properties-> Click on Java build path -> select your JRE file (mostly it will display error) and click on edit button which is on right side -> new dialog box will get displayed as “JRE System Library” in this window select radio button i.e"Workspace default JRE(jre6)" or whichever you have installed.
Then click on finish.
Errors will not come.
The solution to the above problem is, change the JRE system library by doing the following:
Right click on your project and select properties.
Select Libraries from the tab.
Select the current JRE system library and click on edit.
Select either Alternate JRE or Workspace default JRE (Latest version of JRE).
Click Finish and then OK.
On Eclipse Oxygen, follow steps from (1) to (6) shown below figure.
For those who make errors as I do, check whether the error is "'System' cannot be resolved" or "'system' cannot be resolved." In the latter case, capitalizing system will likely cure the problem. In the former case, follow directions above. Only wasted an hour figuring that one out.
I solved the problem a little bit different. That may be because on my computer "java" doesn't work at Windows/cmd.exe because it is not listed in the Windows-PATH variable.
My solution is this:
Project -> Properties -> Java Build Path -> Libraries
Add Library -> JRE System Library -> Alternate JRE -> Installed JREs…
Dialog “Installed JREs” open -> [Add…] -> “Standard VM”
Dialog “JRE Definition” opens -> JRE home: [Directory…]
Select the path to your JRE.
Use [Finish] or [Apply] several time. I hope it also works for you.
I've created a new Java project (testProject) and begin to add jars to a user library, but I'm getting project errors after adding jars to a "User Library"
Here's what I'm doing:Create the User Library
Right mouse click the project and click Properties
Click Add Library..., select User Library, and click Next
Click button, User Libraries...
Click New... and give it a name: mule; click OK.
Select mule and click Add JARs...
Add a jar (e.g. I've added two, one from the root project, log4j.jar, and another from /opt/mule/lib)
Click OK
Click Finish
Now I'm seeing a red x show on the mule library.
1. Click Edit, and click User Libraries
2. The message on each jar says the library is missing, and it seems to be losing the actual path.
See attached image:
I'm running On a Mac OSX 10.5.8, running Java
openjdk version "1.6.0-internal"
OpenJDK Runtime Environment (build 1.6.0-internal-landonf_17_may_2009_13_58-b00)
OpenJDK Client VM (build 11.0-b17, mixed mode)
This doesn't seem to be a problem on a Vista PC, running Eclipse on Java 1.6.0_16. (Or under Ubuntu).
Is anyone else seeing this?
I have had a similar problem in Eclipse Indigo SR2 on a Windows XP workstation. It ran perfectly for a long time until it broke and displayed the behavior that the OP has observed.
I have found out more what causes the problem and have found a workaround.
The problem is caused when I choose Preferences -> Java -> Build Path -> User Libraries | Add JARS... and add a new jar file. What happens is that although the user library is given an absolute path (C:\Documents and Settings\a23456\box_corefx\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar) it only stores a relative path (\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar). This relative path is what makes it say "missing."
The workaround is to export a good user library and massage the jars so that it has entries like:
<archive path="C:/Documents and Settings/a23456/box_corefx/1box-corefx/box-build/target/deployment/weblogic/APP-INF/lib/antlr-2.7.6.jar"/>
Then import the new user library.
There have been a number of problems reported by people trying to run Eclipse on Open JDK. Plus it looks like you are using some sort of pre-production build of it. The first thing I'd do is to try running Eclipse with JDK that comes with Mac OSX.