0

http://docs.oracle.com/javafx/2/text/NeonSign.java.html when I try to run the neonsign java example from oracle in intelliJ this is my error:

Exception in thread "main" java.lang.ClassNotFoundException: NeonSign
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
MT0
  • 143,790
  • 11
  • 59
  • 117
  • Its nice that you are informing us that you have an exception in your program but what is your question and how do you expect us to solve it from the information you have presented? – MT0 Apr 08 '16 at 23:25
  • How can I downvote MT0 for a reply like this. You know if you have nothing to contribute to the conversation just dont say anything at all. – Droid Gamer Apr 09 '16 at 19:20
  • Or you could try amending your question with the source code you are using (do not link elsewhere) and listing the resources and file structure you are including in your project and, if you can, an error message that refers to a line of code in your application (which it doesn't at the moment it refers to `com.intellij.rt.execution.application.AppMain.main` which is the IDE's application for launching your project). As it stands the question is almost impossible to answer as you don't give any information about how you have set up your project. – MT0 Apr 09 '16 at 22:01
  • Possible duplicate of [Error “ClassNotFoundException” in IntelliJ IDEA](http://stackoverflow.com/questions/17300318/error-classnotfoundexception-in-intellij-idea) – MT0 Apr 09 '16 at 22:01

1 Answers1

0

https://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html

public class ClassNotFoundException extends ReflectiveOperationException Thrown when an application tries to load in a class through its string name using: The forName method in class Class. The findSystemClass method in class ClassLoader . The loadClass method in class ClassLoader. but no definition for the class with the specified name could be found.

As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "optional exception that was raised while loading the class" that may be provided at construction time and accessed via the getException() method is now known as the cause, and may be accessed via the Throwable.getCause() method, as well as the aforementioned "legacy method."

I believe this usually happens when you do not have the Library/jar in question added, and have to add it to your current project.

Please make sure you are Using Java 8 (1.8) or you have JavaFX added to your project.

In this case, after looking through the example I found this line of code

scene.getStylesheets().add(NeonSign.class.getResource("brickStyle.css").toExternalForm());

I wonder if the issue is because it's trying to get a resource that doesn't exist (brickStyle.css). If you remove this line, does the error persist?

This might also have to do with you not having JavaFX in your project.


Also, additional reading.

How do I resolve this Java Class not found exception?


Just to add, depending on if IDEA gives you a sample of an FX application, but Netbeans has a FXApplication project with "FXMainClass" that has a built in small example.

Good luck.

Community
  • 1
  • 1
XaolingBao
  • 1,034
  • 1
  • 18
  • 34