The code I'm running is from the homepage of http://www.scalafx.org. There are no compiler warnings but when it runs I get the exception. I first tried using jdk 1.7 with Scala 2.11 and ScalaFX 2.9.3-2.2.67 and got the equivalent error. I still get it with jdk 1.8 with Scala 2.11 and ScalaFX 2.11-8.0.20-R6. I'm hoping I'm stupidly missing something simple. This is all that gets written to the console:
"C:\Program Files (x86)\Java\jdk1.8.0_20\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\jfxswt.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\rt.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.8.0_20\jre\lib\ext\zipfs.jar;C:\Program Files (x86)\scala\lib\scala-actors-2.11.0.jar;C:\Program Files (x86)\scala\lib\scala-swing_2.11-1.0.1.jar;C:\Program Files (x86)\scala\lib\scala-library.jar;C:\Users\bhoeppner\Downloads\ScalaFX 8\scalafx_2.11-8.0.20-R6.jar;C:\Users\bhoeppner\Downloads\ScalaFX 8\scalafx_2.11-8.0.20-R6-javadoc.jar;C:\Users\bhoeppner\Downloads\ScalaFX 8\scalafx_2.11-8.0.20-R6-sources.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain HelloStageDemo
Exception in thread "main" java.lang.ClassNotFoundException: HelloStageDemo
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
Process finished with exit code 1
MarsAtomic and Hot Licks were correct. This is how I got it to work:
Dragged the file containing HelloStageDemo to the src folder, which was already marked as Sources Root.
Right-clicked on the project node and selected "Open Module Settings."
Clicked the "Dependencies" tab.
Clicked the green plus sign and pressed Enter for "Jars or directories..."
Browsed to my projects src folder and Clicked the OK button.
Compiling yielded some scala-reflect errors.
Added my scala\lib folder to module dependencies in the same way as I had my src folder.
Compiled and it ran.
Thanks for steering me straight!
Related
before now, my application has always compiled and executed. I just do my compilation using
jar cvmf mainClass.txt starcoder.jar .class images/.gif images/*.jpg *.bat
I have a
**Windows 7 OS,
Java JDK jdk1.7.0_05,
JRE JRE7,
Connector J mysql-connector-java-3.1.14-bin,
Using a TextPad for development,
The runtime is on C:/Program Files/Java and Java_home**
This application from TextPad, it runs well with the CLASSPATH and executes fine.
The system compiles properly but my JAR file fails to execute
PROBLEM: It fails to find my CLASSPATH on runtine execution(which works perfectly on compile time) giving me this Error
c:\Program Files (x86)\Java\jdk1.7.0_05\bin>java -jar starcoder.jar
ClassNotFoundException: com.mysql.jdbc.Driver SQLException: No
suitable driver found for jdbc:mysql://localhost/starinv?user=r oot
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/mail/MessagingE xception
at serialz.(serialz.java:96)
at serialz.main(serialz.java:240) Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinCla
ssLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(C
lassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 2 more
The CLASSPATH
.;C:\Program Files (x86)\Java\jre7\lib\ext\comm.jar;.;C:\Program Files
(x86)\Java\jre7\lib\ext\mysql-connector-java-3.1.14-bin.jar;.;C:\Program
Files (x86)\Java\jre7\lib\ext\jxl.jar;.;C:\Program Files
(x86)\Java\jre7\lib\ext\mailapi.jar;.;C:\Program Files
(x86)\Java\jre7\lib\ext\mail.jar;.;C:\Program Files
(x86)\Java\jre7\lib\ext\activation.jar;.;C:\Program Files
(x86)\Java\jre7\lib
My connector J file is in the right location but I get an error while executing my JAR file.
I need help to resolve this.
is the same for both my development and runtime environment.
Try calling like this:
java -cp .;"C:\Program Files (x86)\Java\jre7\lib\ext\comm.jar";"C:\Program Files (x86)\Java\jre7\lib\ext\mysql-connector-java-3.1.14-bin.jar";"C:\Program Files (x86)\Java\jre7\lib\ext\jxl.jar";"C:\Program Files (x86)\Java\jre7\lib\ext\mailapi.jar";"C:\Program Files (x86)\Java\jre7\lib\ext\mail.jar";"C:\Program Files (x86)\Java\jre7\lib\ext\activation.jar";"C:\Program Files (x86)\Java\jre7\lib" -jar starcoder.jar
Note that I removed your classpath's redundant "." entries and quoted each path.
I've been browsering the Internet for a couple of hours and I am unable to find an answer to my question. The library I'm trying to add is JGraphT
I'm new to Java and I wanted to add a free graph library. I downloaded all .jar files and then the issues startet. What step by step should I do?
I found information about compiling with -cp or -classpath or addng .jar to CLASSPATH (I'm using Linux and I write my programms in gedit (obligatory for my studies) and compile it with terminal). But I wonder what should I do step by step?
What do I have so far:
I have downloaded multiple .jar and they all sit in one folder with
the xxx.java file I would like to compile
do I need to change CLASSPATH? How to do it? How should I compile and
run my program after changing CLASSPATH? The ordinary way(javac
xxx.java; java xxx) or should I change sth?
or maybe I don't need to change CLASSPATH just add -classpath while
compiling? If so, what should the compile anr run commend look
like?
Also I have already tried using -cp... I'm enclosing my lines in terminal. It compiled correctly, but when I tried to run it, I received strange errors. I'm sure the code is correct since it was given in the library as a way to test wether or not is it installed correctly.
wiktoria#wiktoria-1015PW:~/programowanie/grafy/java/testy$ javac -cp jgrapht-ext-0.9.1-uber.jar: HelloJGraphT.java
wiktoria#wiktoria-1015PW:~/programowanie/grafy/java/testy$ java -cp jgrapht-ext-0.9.1-uber.jar: HelloJGraphT
Exception in thread "main" java.lang.NoClassDefFoundError: HelloJGraphT (wrong name: org/jgrapht/demo/HelloJGraphT)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
wiktoria#wiktoria-1015PW:~/programowanie/grafy/java/testy$
Let's say your class belongs into the package net.example.graph. This means the real name of the class is net.example.graph.HelloJGraphT.
This also means you have a directory structure like this:
project_dir/net/example/graph
Go to the project_dir folder, then try this:
javac -cp <path to jgrapht JAR> net/example/graph/HelloJGraphT.java
java -cp <path to jgrapht JAR> net.example.graph.HelloJGraphT
I am having trouble on setting up classpath on Mac. The following is the code I have attempted,
First I exported the jars using terminal
abc-MacBook-Pro:~ abc$ export
CLASSPATH=$CLASSPATH:/Users/abc/Desktop/IR/luceneJar/demo/lucene-demo-4.0.0.jar: export
CLASSPATH=$CLASSPATH:/Users/abc/Desktop/IR/luceneJar/core/lucene-core-4.0.0.jar: export
CLASSPATH=$CLASSPATH:/Users/abc/Desktop/IR/luceneJar/queryparser/lucene-queryparser-4.0.0.jar: export
CLASSPATH=$CLASSPATH:/Users/abc/Desktop/IR/luceneJar/analysis/common/lucene-analyzers-common-4.0.0.jar
Then when I echoed the classpath, following is the result
abc-MacBook-Pro:~ abc$ echo $CLASSPATH
/Users/abc/Desktop/IR/lucene-4.0.0 2/core/lucene-core 4.0.0.jar:
/Users/abc/Desktop/IR/lucene-4.0.0 2/demo/lucene-demo-4.0.0.jar:
/Users/abc/Desktop/IR/luceneJar/analysis/common/lucene-analyzers-common-4.0.0.jar
The error I am having is following when I tried to function the index file
abc-MacBook-Pro:~ abc$ java org.apache.lucene.demo.IndexFiles -docs
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/demo/IndexFiles
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.demo.IndexFiles
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Please let me know about the above error, thank you in advance. I am quite new with Lucene Java.
This is common Java classpath problem, nothing related to lucene (or mac) here.
Try this
1) Create lib folder and move all your lucene jars to lib
- lets say your project has two folders now lib and src, lib has all jars and src has yourJavaFile.java
2) Run below commands for compilation and execution from your src
- javac -cp ".:../lib/*" yourJavaFile.java
- java -cp ".:../lib/*" yourJavaFile
I stumbled upon a weird error while using JDBC sqlite with org.sqlite.JDBC
my code compiles and runs fine on Windows.
But when I tried moving it to Ubuntu it started showing this:
Exception in thread "main" java.lang.ClassNotFoundException: org.sqlite.JDBC
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at mall.SQLiteJDBC.<init>(SQLiteJDBC.java:27)
at mall.AllegroReader.<init>(AllegroReader.java:33)
at mall.Mall.main(Mall.java:31)
I'm running it with java -classpath "sqlite-jdbc-3.7.2.jar" -jar Mall.jar" and java -classpath "sqlite-jdbc4-3.8.2-SNAPSHOT.jar" -jar Mall.jar
with both versions in the same directory as my jar and I've tried a dozen different options specifying classpath and it behaves exactly the same. I tried openjdk and oracle jdk.
I tried rebuilding it on Ubuntu, changing ant .xmls, changing paths, etc.
I have no idea what is going on. Pls help.
Here is what happens inside my dist directory:
work1#workwork:/var/www/mall/dist$ ls
mall.db Mall.jar Mall.jar.old sqlite-jdbc-3.8.4.3-SNAPSHOT.jar
work1#workwork:/var/www/mall/dist$ java -classpath "sqlite-jdbc-3.8.4.3-SNAPSHOT.jar:Mall.jar" Mall
Error: Could not find or load main class Mall
The classpath is ignored when you use -jar.
You have to either include the dependencies in the jar (or at least have the jar manifest point to them), or run it with -classpath sqlite.jar:Mall.jar the.main.class.
Error: Could not find or load main class Mall.main. all files are there,
my main class comes from Mall.java and is in mall package which
compiles to Mall.jar
So the correct command line is:
java -classpath "sqlite-jdbc-3.8.4.3-SNAPSHOT.jar:Mall.jar" mall.Mall
OP findings
to view the classes in jar use jar tf Mall.jar - from this I got mall/Mall.class meaning my class containing main was mall.Mall
it showed
mall/Mall.class
so I should have used mall.Mall as the class to run (instead of pulling my hair)
After spending over 6 hours total with many failed attempts at running "portable" jar package using classpath and whatnot, after having tried OneJar and jarjar to no avail (ended up with Class file too large!) I decided to write the offending piece of code in PHP.
It proved to be more portable than Java in my case.
I set up all my environment variable correctly but I'm getting a weird error, there is no match on google for the class name (which is just giberish)
So I added the 2 required environment variable :
JAVA_HOME C:\programs\Java\jdk1.6.0_41
M2_HOME C:\dev\apache-maven-3.0.4
And added this at the end of the variable PATH
;%JAVA_HOME%\bin;%M2_HOME%\bin
And when running mvn --version I get :
Exception in thread "main" java.lang.NoClassDefFoundError: ûXX
Caused by: java.lang.ClassNotFoundException: ûXX
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: ÔÇôXX. Program will exit.
The weird thing is that I get exactly the same thing on 2 totally different computers.
I tried with old file that I already had and freshly downloaded files.
I don't get it.
This works on my PC with Win7 64x OS:
JAVA_HOME c:\Program Files (x86)\Java\jdk1.6.0_21
J2_HOME c:\Program Files (x86)\Java\jdk1.6.0_21\bin
M2_HOME c:\Program Files (x86)\apache-maven-3.1.0
PATH ...;%M2_HOME%\bin;%J2_HOME%
Sometimes, when we want get PATH without spaces, we can use this trick:
'Progra~1' instead of 'Program Files'
'Progra~2' instead of 'Program Files (x86)'
and etc
This is old DOS filenames style: 8+3 - where 8 chars for name and 3 for extension (if it present)
This works on old Win machines
when passing maven path try to come in to maven package and get path, I had a maven package inside of maven package,so my path is C:\apache-maven-3.6.0\apache-maven-3.6.0. it is work on my computer.