I'm trying to execute carel programs based on CSA106a Stanford class videos available on YouTube.
I've downloaded the jar and related files, imported the whole project into Neon Eclipse and am trying to run.
While clicking "run", I get the error:
Error: Could not find or load main class (default package).CheckerboardKarel
Note: other programs that I have created in Neon from scratch are working fine (not imported ones). Please help.
I've attached the screenshots as well.
I can't tell for sure, but I think there might not be a "main" function in what you downloaded. In order for a java program to run the class you are running needs to have a main function. it should look like:
public static void main(String[] args){
...
}
Related
I made a java application using javaFx on Eclipse IDE.
I am using JavaSE-11 compiler and the javafx-sdk-11 version.
It works when I run it from Eclipse, but now i'm trying to make a runnable .jar of the application.
When I double click on the .jar, nothing happens. I tried installing, uninstalling and reinstalling Java ...
Here are the issues I'm having when I try to launch it with [java -jar filename.jar] command :
Extracting the required libraries into generated JAR
java : Error : JavaFX runtime components are missing,
and are required to run this application
Packaging the required libraries into generated JAR
java : Graphics Device intialization failed for : d3d, sw
Error initializing QuantumRenderer : no suitable pipeline found
Don't hesitate to ask me more details, I'm not very good at this but I'm trying my best.
Thanks
I had same problem few days back. I just made another class that doesn't extend Application, and has its own main. Then just launched the application from that class like so:
public class Fakemain {
public static void main(String[] args) {
game.main(args); //this is the class that extends Application
}
}
Let me know if this worked for you.
I am facing a problem while i am trying to compile a code at eclipse in java. The code is the following:
public class New {
public static void main(String[] args){
System.out.println("hello world");
}
}
Parts that have errors are New, String and System. I have checked at error list and the description for error's is like:
Unable to create editor ID
The file does not exist
Any idea why this is happening?
Your project has or classes maybe has beeing dissapeared.
I can give you a possible solution
Solution: Shut down Eclipse IDE Start Eclipse IDE (with -clean to be super-safe) Reimport all projects (UPDATE: Just use File->Import->Existing Project into Workspace and browse your workspace/project directory)
This is my first time with Java and Eclipse. I started a brand new Java project and I want to import/add NanoHTTPD into it. How do you this?
This is NanoHTTPD's site: http://nanohttpd.com
Thanks!
Edit
Lesson learned, be specific or you get backslashed for asking. I edited the question and here's some background and the problem I'm running into.
I'm developing a Nodejs backend that needs to query a JAVA project I was given. Pipes are a no go because the services will run on different machines. Tomcat seems like an overkill so I decided to use NanoHTTPD to develop the web service. I come from Ruby & Nodejs so compilation and Eclipse are very new to me. First off, I have no JAR file just TAR and ZIP and from what I read they are fundamentally different. However, I tried importing the TAR and ZIP files as recommended but the structure I get in Eclipse does not seem right compared to the JRE System Library or others I've seen. Notwithstanding, I went ahead and tried to import the package from my Main.java file
package fi.iki.elonen;
public class Main {
public static void main (String[] args)
{
System.out.println("Main");
}
}
When I try to run it I get the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at Main.main(Main.java:4)
I found a great article from IBM "Managing the Java classpath (UNIX and Mac OS X)" where it mentions that an IDE such as Eclipse can alleviate the pain of dealing with the source path, classpath and compilation. Unfortunately, I'm afraid this is where I might be getting stuck.
I tried uploading images of what I have but apparently I'm not popular enough yet to do it.
Could someone help me figuring out how to not only import libraries but using them on projects? Even just a URL to a clear Linux/Mac OS X post that explains import with multiple packages would be great.
NanoHTTPD is designed to be very lightweight.
I just cut and pasted the 'NanoHTTPD' class from the source on github, its all in there - and pasted it as a class into my own project.
Then I created a subclass of nanoHTTPD, overrode the 'serve' method to send my own stuff and it was job done.
Download the jar, drag it into the project, and right-click it to add it to the build path.
I am using jdk 1.8 , jre 1.8 and eclipse juno.Whenever i use to run my program with eclipse it gives me this error
Error: Main method not found in class A, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
my basic program is
public class A {
public static void main(String[] args) {
System.out.println("Hello");
}
}
Then i tried to run my program from CMD on the first time it run successfully after that it also start giving me this error..Points to remember
When i create a new project i use default jre.which is jre 8.
I am not using any kind of javaFx Application.My basic program is in front of you all
I cant every time extend javafx .So i need a strong way to resolve it.
I run a program from the command prompt for the first time it run ,but when i run another program with little bit of change it did not run.
I am stuck here guys please give me a solution for that and a little bit of explanation for that will be appreciated..
Please, close your cmd prompt.
And reopen cmd prompt.
Then open your directory containing pom.xml
To build your project, Type : mvn install
Then run the java code. For eg,
java -cp target/sample-0.0.1-SNAPSHOT.jar com.maven.sample.HelloMaven
Here HelloMaven is the class name.
I had the same error. Imported java.lang.String and the error went off.
import java.lang.String;
I had a project that was compiling and running fine. I had also exported the build.xml file without issue. However, today, I clicked Project --> Clean..., and the project will no longer run. It raises the error:
Error: Could not find or load main class com.bar.Foo
Is there any way I can undo this?
The answer is probably no, you cannot "undo" this. You can probably fix it by building your project, making sure that the project/class exists and that it contains a public static void main(String ... args) method.
Perhaps the file that you're trying to run was removed from the src folder.