Using java 1.9 (b132), Eclipse Neon (4.6.0), I am working through a large legacy java client front end project in preparation for java 9. Most of the code works, but this problem I cannot resolve. I have added the following to the eclipse.ini:
...
-vm
C:/Program Files (x86)/Java/jdk-9/bin/javaw.exe
...
--add-modules=java.se.ee
My problem can be easily replicated in a simple example in Eclipse:
public class HelloWorld {
public static void main(String[] args) {
System.setSecurityManager(null);
}
}
Eclipse will not build this, giving: 'The type java.lang.SecurityManager cannot be resolved...'
Tried adding -Djava security.manager to the eclipse.ini but that did not load.
Any help would be appreciated.
With Java 9 release candidate and Eclipse Oxygen 4.7.1a, this should be fixed. You can find out how to configure eclipse with Java 9 here.
Moreover to access :
java.lang.System.setSecurityManager(null);
you don't need to use --add-modules java.se.ee since the java.lang package is exported by the java.base module of JDK itself. So the code sample as shared in the question should compile with a sample module-info like the following as well:
module your.new.modules { }
Related
I am using Eclipse Version: 2019-06 (4.12.0). For my Rest Assured project, I have downloaded and added the JAR files from the path https://github.com/rest-assured/rest-assured/wiki/Downloads. For the keyword "RestAssured" Eclipse should suggest to import the package which is missing. Can anyone please help me in fixing this?
*package com.RestAssured;
public class Basic {
public static void main(String[] args) {
// TODO Auto-generated method stub
RestAssured.
}
}*
[Java Build Path][1]
[1]: https://i.stack.imgur.com/sl0Dr.png
[Eclipse UI][2]
[2]: https://i.stack.imgur.com/62e5v.png
Try deleting the existing java plugin, if u are using java version above 1.8 and install both jdk and jre (1.8) and add those in the system External variable and check when creating a new project in eclipse, verify the execution environment is in JavaSE-1.8. Try this
Using Eclipse 2018.12, I've installed the Eclipse Kotlin plugin (0.8.20.20200316-1305), created a Kotlin project (using the "New..." options under "Kotlin") and wrote a "Hello World!" program:
Test.kt:
fun main() = System.out.println("Hello World!")
However, when I try to run it I get the message
Error: Could not find or load main class TestKt
Caused by: java.lang.ClassNotFoundException: TestKt
Upon further inspection it seems the class has never been compiled. There is no corresponding .class file anywhere. Under the project directory I see Eclipse configuration directory .settings and files .project and .classpath. Besides that, I have an empty bin directory and a src directory with Test.kt only.
I found two similar questions about this in SO:
In Unable to Run Kotlin Application in Eclipse, the accepted answer simply indicates working with a new version of Eclipse and Kotlin plugin, both older than what I have now. Besides, the problem may have been solved in that case due to a new installation rather than the version.
Kotlin - Error: Could not find or load main class _DefaultPackage is quite old and the accepted answer does not apply anymore. It was about not naming the main class properly, but in my case there is not even a byte code file to be found.
Running "Project -> Compile Kotlin classes" had no effect.
How can I get this simple example to run?
Update: I've updated to 2020-06 (not that it should matter since Eclipse Kotlin lists 2018-12 in its requirements) and replaced Zuly by AdoptOpenJDK HotSpotJDK 11. The error persists. The Eclipse log does not show any related messages.
Update 2: re-created the project in a brand-new workspace but the problem persists.
I'm trying to use NetBeans for a JDBC project. However, I'm getting runtime errors when I try to compile. I decided to try a "hello world" project and I couldn't get that to run also. I'm in NetBeans 9.0 with Java JDK 10.0.2.
Error Message:
Exception in thread "main" java.lang.RuntimeException:
at javaapplication2.JavaApplication2.main(JavaApplication2.java:1)
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 1 second)
xml debug:<call-java classname="#{classname}" classpath="#{classpath}" modulename="#{modulename}" modulepath="#{modulepath}">
package javaapplication2;
public class JavaApplication2 {
public static void main(String[] args) {
System.out.println("Hello");
}
}
It is very easy, your JDK version is not 100 % compatible; use version 8.2, which is the most stable for Arduino and others.
To change platforms without deleting the existing one, simply go to Tools / Java Platforms / click on the button add Platforms.
Download/install JDK major version number the same as NetBeans.
i.e. If You have NetBeans 9 version, but your JDK is version 10,So try use NetBeans 10 version... or download/install JDK 9 (the same as NetBeans).
Create new java platform for new jdk installation.
Open netbeans menubar->tools->Java Platforms->Add Platform Specify the folder that contains the Java platform as well as the sources and Javadoc needed for debugging.
Set new java platform to your project
Right click on project ->properties->Libraries->Java Platform->select the jdk version that same as NetBeans.
Select source format of your project
Right click on project ->properties->Sources->Sources/binary format->select the jdk version that same as NetBeans.
If it still give same error,Open the project properties, select the Build-Compiling, uncheck "Compile on save" and rerun the application. This will make sure all your source code becomes recompiled before running it.
I am doing a CIMTool project, for a handle of WorkbenchWindow
Code Snippet
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
//(both these Classes are present in Libraries)
IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
Issues
Following Error is slapped
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/e4/ui/model/application/ui/MUIElement
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:90)
Environment
Eclipse : Eclipse Java EE IDE for Web Developers, Version: Juno Service Release 2
OS : MS Windows 7 Professional, X86
Java Version : java version "1.7.0_25"
Questions
I tried searching for org/eclipse/e4/ui/model/*, I could not find in
Archives. Where I can find ?
Is there any otherway to get IWorkbenchWindow Instance ? (want to
avoid this issue)
This problem I found that, doesnt appear in Java Indigo. But my project has to be developed in Eclipse , so I cant migrate.
thanks
I also was confronted with this error when executing code from within a project that was created as "SWT/JFace Java Project" using Eclipse Kepler (displaying a ListSelectionDialog).
The main problem is that the project set-up misses a JAR file that contains the MUIElement class. You can easily fix the project set-up by editing the build-path, adding the external jar which has a name similar to this one:
org.eclipse.e4.ui.model.workbench_1.0.1.v20131118-1956.jar.
You find that jar in the plugins directory of your Eclipse installation.
After about 6-7 hours in a row, I'm hoping that somebody can help me with a problem I am having.
Basically I'm trying to develop a Eclipse plugin containing both Scala and Java code. Unfortunately it is such that when I'm trying to build the plugin, I get errors of this kind:
File: #dot.log
04-04-12 19:02:49 CEST Eclipse Compiler for Java(TM) 0.A76_R36x, 3.6.2, Copyright IBM Corp 2000, 2010. All rights reserved.
ERROR in C:\Documents and Settings\b96274\workspace_scala_akka\TestScala\src\testscala\Activator.java (at line 16)
ScalaTest t = null;
^^^^^^^^^
ScalaTest cannot be resolved to a type
1 problem (1 error)
The two classes I have defined are:
"Activator.java"
package testscala;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
ScalaTest t = null;
}
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}
"ScalaTest.scala"
package testscala
class ScalaTest {
val t = "whatever"
}
I create the plugin as first a Plugin Project, and the afterwards add Scala nature to it.
To inform the PDE builder of scala I have used: http://www.michel-kraemer.com/scala-projects-with-eclipse-pde-build-2
Michel Kraemers very excellent build file.
My build.properties file is:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
customBuildCallbacks=customBuildCallbacks.xml
customBuildCallbacks.inheritall=true
and the customBuildCallbacks.xml is stored in the buttom of the project.
I have tried with nightly and the stable build branch of the Scala IDE plugin. Also fresh versions of Eclipse 3.6.2 and 3.7.2 have been tried.
I have gotten plugins working before with this setup, unfortunately I seems to have been forgetting some (basic?) stuff.
I can use the workaround "Use class files compiled in workspace", but I need the PDE builder to work with this.
Can anyone please help, I will of course give more details if needed.
My guess is that the Java compiler can't see compiled Scala files since they first will be compiled later, but that's only an guess.
Thanks in advance.
Regards Stefan Ettrup
I am also using this approach. Basically, I believe it doesn't support Java code depending on Scala code, because the Java compiler has to run first and it it fails, Scala compiler isn't even tried. At least that was my experience. Of course, Java code can depend on Scala code in other plugins, because it only ever sees bytecode from there.
The java compiler does not understand scala files, but the scala compiler does parse/understand java files. The scala compiler does not, however, compile java files, it only compiles scala files. So, to compile a combined java/scala plugin, you generally have to:
1) Compile your scala, including your java source tree. This generates the .class files for your scala files.
2) Compile your java, including the .class files generated above. This generates the .class files for your java files. Anything java which depends upon the scala classes should be compiled correctly.
So do the scala compilation first. Sometimes, you'll need to add a third step, to compile your scala again, using the class files generated by the java compiler. But this is rare.
I'm afraid I don't know how to do this with ant, but I'm sure it's possible.
For scala-ide, this is even easier, because there is an option in Window->Preferences->Scala->Compiler tab Build manager, you can choose compileorder (Mixed, JavaThenScala, ScalaThenJava). Try this as well.