This is shown in the console of MyEclipse when trying to run a simple "Hello world" program. Sort of surprised that noone has a solution yet.
I think this should be such a basic issue that should be addressed, but couldn't find it being resolved anywhere.
Problem:
I am getting the following error Message when trying to run a small Java program. I assume it might be a "setup error" or "compiler error" of my Eclipse but not sure. I cannot re-setup because I have enterprise Java being setup here. That took a boatload of time. So have to resolve without any re-installations and such.
In red it shows as:
Usage: java javassist.tools.reflect.Compiler
(<class> [-m <metaobject>] [-c <class metaobject>])+
To make sure that it is not an issue of my program, I made a new class where I tried to print "Hello World".. and still I get the same error message where it did not display the output.
So I figured it out myself. This is a Run configuration issue.
Right click your project --> Run As --> Run configuration --> Under the "main class" input box enter your fully qualified class name where your main() resides. Or the better way would be to click the "Search" button near to it and select the appropriate package.
Make sure it is running as a "Java Application" or under the correct "Server".
It should be resolved for the most part.
Anyways it is a Run configuration issue.
Related
The error is as the pic showed:
Could you run it directly? It does not look like a problem with Java.
You can intentionally make a compile error and you can clearly see which provided this error message. Most of it was provided by the Java Language Server so you can find 'Java(xxxxx)' at the end of the error message. But the error message in the picture you have provided does not contains it.
So could you disable all extensions and then just enable Java-related extensions to check the error message still exists or not?
Remove public class and make it class only. IDE is showing error because You have same class name somewhere in another java file. I don't know why but this issue arise in VSCode. If you run your code using cmd than your code will show no error.
I am trying to do my first test-automation with Spock.
I do not want to use maven.
I am using eclipse java EE oxygen 4.7.
I have created a groovy project.
I have added the Spock jar as an external library in the build path configuration.
Spock ist Spock-core-1.1-groovy-2.4.
I have also added geb jar the same way.
However, I am getting this strange error from the automatic build, which I do not understand and I am seeking for help. So far I haven't found anything helpfull.
General error during semantic analysis: Transform org.spockframework.compiler.SpockTransform#xxxx cannot be run org.codehaus.groovy.GroovyException:
Transform org.spockframework.compiler.SpockTransform#xxxx cannot be run at
org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:416) at
org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:972) at
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609) at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586) at
org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:217) at
org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUnitDeclaration.java:613) at
org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:879) at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:141) at
java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoClassDefFoundError: Unable to load class org.spockframework.runtime.ErrorCollector due to
missing dependency org/junit/runners/model/MultipleFailureException at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:397) at
org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:353) at org.codehaus.groovy.ast.ClassNode.getDeclaredMethods(ClassNode.java:981) at
org.codehaus.groovy.ast.ImmutableClassNode.getDeclaredMethods(ImmutableClassNode.java:105) at
org.spockframework.compiler.AstNodeCache.(AstNodeCache.java:65) at org.spockframework.compiler.SpockTransform$Impl.(SpockTransform.java:
52) at org.spockframework.compiler.SpockTransform.visit(SpockTransform.java:47) at
org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:395) ... 9 more
My code is as simple as you can get. This is the code:
//The error is on the "p" letter of package
package hellowworld
class HelloWorld{
static main(args) {
}
}
Please note that this error only happens when I add Spock jar. The closest question was Spock without maven or gradle, but obviously the problems are different.
I just cut the file from the package directory pasted it out side and then recut pasted in the package back. It worked well and I have no idea why.
This is one of those problems which occasionally arise in Eclipse and most people just won't know why!
The thing to do usually is to try several "strategies" and hope that one will work. If not you have to come back to SO and try to enlist the support of an expert.
One tip: in my experience sometimes it is worth trying "Refresh Gradle" and "Build all" more than once. Not only that, but sometimes trying either of these actually then seems to do nothing... but a couple of seconds later the horrid x in the red box then vanishes like morning mist!
Highlight/select the project in Project Explorer --> right-click --> Gradle --> Refresh Gradle Project
Put cursor in a code file open in the editor, press Ctrl-B (Project --> Build all)
Close all files in editor, close Eclipse and start up Eclipse again
Try the above in various combinations
Reboot and then try the above in various combinations
If this fails to cure it you may need to turn to SO.
I've experienced a really weird behaviour when using Netbeans today. Firstly, I get Error: Could not find or load main class <name of my class> at random. I know what this means but I don't change anything, it appears and disappears randomly. Secondly, when I modify the code e.g. adding a line System.out.println("x"); that I am 100% sure should be executed, Netbeans seems to overlook that modification and run the old version of the code (before System.out.println("x"); was added) so as a result it doesn't get printed.
Both errors appear at random and last for some time, then disappear and appear again and so on. I've been trying to fix them for 2 hours but to no avail. They make me unable to do any work with Netbeans.
EDIT: Reinstalling Netbeans and Java didn't help. When I load the same project in Eclipse, everything works correctly.
Make sure your class has a public qualifier. Also the name of the file and the class containing the main method should be same.
NetBeans docs at http://docs.oracle.com/javase/tutorial/getStarted/cupojava/netbeans.html say:
If the build output concludes with the statement BUILD FAILED, you probably have a syntax error in your code. Errors are reported in the Output window as hyper-linked text. You double-click such a hyper-link to navigate to the source of an error. You can then fix the error and once again choose Run | Build Main Project.
However, in NetBeans 7.0.1, the hyperlinks are mostly missing. (I'm running in Linux Mint 12.) The errors are plain text and navigating to them is a pain. This is true for all errors except for two at the end which are hyperlinked. The two that are hyperlinked are of no immediate use to me. They are:
/home/user/Workspaces/MyApp/client.git/nbproject/build-impl.xml:603: The following error occurred while executing this line:
/home/user/Workspaces/MyApp/client.git/nbproject/build-impl.xml:284: Compile failed; see the compiler error output for details.
All the places I need to edit in the code are mentioned by file and line number, but are not hyperlinked:
MyApp.java:40: cannot find symbol
symbol : constructor MainView(com.example.desktopclient.MyApp)
location: class com.example.desktopclient.MainView
MainView mainView = new MainView(this);
Does anyone know anything about this issue. I searched but didn't find anything relevant.
EDIT: I'm NOT looking for help with the code errors! I want to find out why NetBeans isn't working correctly.
I get the following error when I try to start my code in the debugger.
EventDispatchThread.run() line: not available [local variables unavailable]
The code is very large and I can't publish it here but anyway here are some details:
This statement seems to crash and I can't step into the constructor with the debugger:
Satellite satellite = new Satellite();
When I put a breakpoint on this line and try to step into the constructor or step over I get the same error as above.
Here are parts of Satellite class implementation:
package tags;
import main.*;
import xml.*;
public class Satellite extends XMLElement {
public static final String[] ATTRIBUTES = {
"XmlFileVersion",
"SatelliteName",
"xmlns:xsi=#xmlns_xsi",
"xsi:noNamespaceSchemaLocation=#xsi_noNamespaceSchemaLocation"
};
public Satellite() {
super(ATTRIBUTES);
setTopLevelElement();
setAttribute("XmlFileVersion",ValueCenter.Satellite_XmlFileVersion());
setAttribute("SatelliteName",ValueCenter.Satellite_SatelliteName());
addElement(new SubSystemList());
}
}
I localized the problem somewhere in the line addElement(new SubSystemList()); . I added a breakpoint here and again tried to step in or step over and now I got a ClassNotFoundException. The debug cursor jumps to an empty window where "Source not found." is written but the Source is 100% available and I also got the corresponding .class files. The other thing is that the Eclipse IDE throws no errors on the syntax check.
I don't understand this. What can cause these errors and why can't I use the debugger to walk through the method calls?
I've updated the Eclipse Helios SR1 for Java Devs and installed the latest java version on my pc.
I know that the code has an endless loop anywhere in here because I get an StackOverflowError Exception if I run it without the debugger. But anyway, shouldn't it be possible to debug through the code, to investigate the real problem? Why is the debugger crashing with other errors or exceptions than a non debugger run?
btw: only one thread and sequential execution.
Hope someone can help.
Edit 1:
Some additional infos. My Workspace has two projects. In one there is the main program with the Satellite and others. In the other project I have many supporting classes like this XMLElement. This structure works for many classes.
By the way: I can step into the XMLElement.setAttribute method but I can't step into the XMLElement.addElement.
The other strange thing is that Satellite is in the same project as the main class but it's also not possible to step into the constructor.
Maybe this helps?
In Eclipse: Right-click the project and select Properties.
Here are the settings you have to change:
Also, find your Run Configuration using Run > Run Configurations ..., select the Source tab and make sure the current project is in the sources list. If not, click Add... > Java Project ...
EventDispatchThread.run() line: not available. This is a common error message for java desktop application developer, who are mainly working in Swing. I also got the same error message but the step you explained doesn't solve my prob.I got the same error message for another issue.That was OutOfMemoryError.So when you are getting this error message the problem you need to find yourself and it's not due to some particular issue.
I resolved this by fixing my Java Swing Code which was throwing NullPointerException.