I am new to using the Jetty server. For starting Jetty v8.1 Using the command prompt, I need to navigate to the jetty-distribution-8.1.16.v20140903 folder and run the command: java -jar start.jar.
In case I don't navigate to the jetty-distribution-8.1.16.v20140903 folder and try to start the command using: java -jar C:\jetty-distribution-8.1.16.v20140903\start.jar then I get an FileNotFoundException :
java.io.FileNotFoundException: No XML configuration files specified in start.con
fig or command line.
at org.eclipse.jetty.start.Main.start(Main.java:502)
at org.eclipse.jetty.start.Main.main(Main.java:96)
Usage: java -jar start.jar [options] [properties] [configs]
java -jar start.jar --help # for more information
What are the files does it looks for while starting the server? Please let me know how to start the jetty server without navigating to the distribution folder.
Edit:
When I tried this command:
java -Djetty.home= C:\jetty-distribution-8.1.16.v20140903 -jar C:\jetty-distribution-8.1.16.v20140903/start.jar
I got the below error:
Caused by: java.lang.ClassNotFoundException: C:\jetty-distribution-8.1.16.v20140
903
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: C:\jetty-distribution-8.1.16.v20140903. Program
will exit.
Please suggest.
Try this:
java -Djetty.home=C:\jetty-distribution-8.1.15.v20140411 -jar C:\jetty-distribution-8.1.15.v20140411/start.jar
According to the Jetty documentation Running Jetty the correct way to start the Jetty server is:
cd $JETTY_HOME
java -jar start.jar
Do you have $JETTY_HOME defined?
If so you can just write a small script, eg called RunJetty or Jetty that contains the above commands. The script could even restore the current directory as well ...
The startup of Jetty 8 is old and now very different than Jetty 9.
Important Note: Jetty 8 is soon EOL, would highly encourage upgrading to Jetty 9 pronto.
For Jetty 8, the ${jetty.home} path is where everything takes place (aka your jetty-distribution directory).
For Jetty 8, it looks for a ${jetty.home}/start.ini and then starts to build up the command line, xml files, properties, start.d OPTIONS declarations, etc to start your environment.
For Jetty 9, this is radically different, there is a clear split between ${jetty.home} the unmodified distribution, and a new ${jetty.base} where you configure for your specific jetty instance. You can even have multiple ${jetty.base} directories for different instances. There is even support for a tiered ${jetty.base} declaration to further separate roles in an organization (ops installs jetty-dist into a common ${jetty.home}, configures a infrastructure ${jetty.base} to handle logging and monitoring, and the application is in its own ${jetty.base}, at which point all 3 are combined to form the configuration that instance uses)
Related
What is the difference between starting java process by:
java -jar application.war
and
java -classpath application.war org.example.Main
Problem is that I'm starting Spring Boot Application with -jar argument, process starts normally, but in eclipse application starts with exception:
Caused by: java.lang.ClassNotFoundException: com.sun.istack.localization.Localizable
When you launch your app with
java -jar application.war
It will read your MANIFEST.MF and pick up your classpath from there, including presumably your missing com.sun.istack.localization.Localizable.
When you specify the classpath as the war, it finds your Main class but does not include the values from the MANIFEST.MF.
Related to : Executing rake tasks on an exploded war on tomcat without jruby being installed
I'm trying to run rake tasks in my Tomcat server that doesn't have JRuby installed. I'm using warbler to create a war file.
Using the answer to the linked question, I ran:
java -cp lib/jruby-core*.jar:lib/jruby-stdlib*.jar org.jruby.Main -S rake -T
This gets me the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
ls lib gets me:
ems-gems-activerecord-jdbc-adapter-1.2.2-lib-arjdbc-jdbc-adapter_java.jar
gems-gems-jdbc-sqlite3-3.7.2-lib-sqlite-jdbc-3.7.2.jar
gems-gems-jruby-jars-1.6.8-lib-jruby-core-1.6.8.jar
gems-gems-jruby-jars-1.6.8-lib-jruby-stdlib-1.6.8.jar
gems-gems-jruby-rack-1.1.10-lib-jruby-rack-1.1.10.jar
gems-gems-json-1.7.5-java-lib-json-ext-generator.jar
gems-gems-json-1.7.5-java-lib-json-ext-parser.jar
gems-gems-therubyrhino_jar-1.7.4-jar-rhino-1.7R4.jar
gems-gems-warbler-1.3.6-lib-warbler_jar.jar
jruby-core-1.6.8.jar
jruby-rack-1.1.10.jar
jruby-stdlib-1.6.8.jar
ojdbc6.jar
Opening up the jruby-core-1.6.8.jar file, I can see that there is indeed a org/jruby/Main.class file.
As one can see from the file listing, there is no jruby-complete jar file, so I can't run the command from https://stackoverflow.com/a/9982556/684934
What am I doing wrong, and is there by now a better way to do this?
I was working on a similar problem 2 months ago, so things may have changed, but I needed to include all the jars in my class path, had to use bin stubs, and had to set GEM_HOME to get everything working. It may have been simpler, but the posts you referenced didn't work for me either.
I actually had jruby installed, (but I was only using it to build the concatenated class path), so my setup was something like:
cd /path/to/application/
export GEM_HOME=/path/to/application/gems
export CLASSPATH=$(jruby -e 'puts Dir["lib/*.jar"].join(":")')
RAILS_ENV=production java -cp $CLASSPATH org.jruby.Main bin/rake -T
Also useful, the jruby-jars gem can be included in your gemfile to set the version of jruby that warbler includes (I was using gem 'jruby-jars', '1.7.0.preview2' as 1.7.0 wasn't released yet)
I am new to ubuntu 10.10 and am using it as VM. I tried installing jdk 1.7 to run java programs from terminal. I followed the instructions from the link: How to Install Oracle Java on Ubuntu Linux. After installation was complete, i tried to test run a Hello World java program. The program compiled successfully when i did javac Hello.java. However when i tried to run the program using java Hello, it didnt give any output on the terminal and gave me the following:
Unable to launch the application.
Exception:
CouldNotLoadArgumentException[ Could not load file/URL specified: Hello]
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Wrapped Exception
java.io.FileNotFoundException: Hello (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Further i tried checking my version for java using java -version and it gave the following output:
Java(TM) Web Start 10.0.0.147-fcs
Usage: javaws [run-options] <jnlp-file>
javaws [control-options]
where run-options include:
-verbose display additional output
-offline run the application in offline mode
-system run the application from the system cache only
-Xnosplash run without showing a splash screen
-J<option> supply option to the vm
-wait start java process and wait for its exit
control-options include:
-viewer show the cache viewer in the java control panel
-clearcache remove all non-installed applications from the cache
-uninstall remove all applications from the cache
-uninstall <jnlp-file> remove the application from the cache
-import [import-options] <jnlp-file> import the application to the cache
import-options include:
-silent import silently (with no user interface)
-system import application into the system cache
-codebase <url> retrieve resources from the given codebase
-shortcut install shortcuts as if user allowed prompt
-association install associations as if user allowed prompt
I see here that its using javaws when i try to run program using java.
I dont understand why this is happening or what is going wrong. Any help would be very much appreciated. Am just a beginner on Ubuntu.
Thanks in advance!!
Edit 1
Hello.java:
public class Hello
{
public static void main(String... s)
{
System.out.println("Hello World.!!!");
}
}
Your output from java -version give you the ouput from javaws -version.
So this seems to be a linking error in your filesystem.
If you use update-alternatives, you create a symbolic link in your binary-folder (/usr/bin).
Maybe you had some typo while going through the tutorial?
I'm pretty sure it was something like
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_05/bin/javaws" 1 or something like this.
You could try to reenter the "update-alternative" commands.
I am not sure you want 10.10 when 12.04 is available. I installed the Sun/Oracle version and it worked first time. All you have to do is download it, unpack it and add it to your path.
The error message suggests Java is not installed correctly.
I suggest you also install a free IDE like IntelliJ CE. This will make writing, compiling, running and debugging your application much easier.
The version of Ubuntu I use provides FOP 0.95. Its having problems, so I wanted to try the latest version of FOP. I successfully downloaded and built the sources.
Unfortunately, I can't figure out how to install FOP 1.0. The build instructions (https://xmlgraphics.apache.org/fop/1.0/compiling.html) did not cover the topic, and the README does not offer any instructions.
I naively tried ant install --prefix=/usr/local which failed. Ant listed its flags and switches, but did not include an install option. Next, I performed sudo cp ./fop /usr/local/bin, which resulted in the following
$fop -V
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/cli/Main
Caused by: java.lang.ClassNotFoundException: org.apache.fop.cli.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.apache.fop.cli.Main. Program will exit.
How does one install a program with Ant?
Jeff
Uncompress the download to a directory.
Add that directory to your path.
export PATH=~/tech/lang/java/fop/fop-1.0/:$PATH
That's it:
Daves-MacBook-Pro:~ Dave$ fop -V
USAGE
fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>
[OPTIONS]
-version print FOP version and exit
-d debug mode
-x dump configuration settings
# etc...
Welcome to the world of PATH and environment variables in Java.
The error is being caused because java cannot find the class libraries it requires.
You will find that fop is a script which invokes java with the appropriate parameters for this java application.
You also need to check your java installation and make sure everything is straight.
First: I realize that this issue should be quite simple and lots of people seem to have experienced it. However, it appears my issue may be slightly different from existing posts.
I'm using NetBeans to compile a Java application. When it's done building, the output goes into the dist\ folder correctly. The jar file is present there. If I go to the command line, navigate to that folder, and call the following:
java -jar Prosperity.jar
everything works fine. Obviously the name of the application is Prosperity. The following command also works fine:
javaw -jar Prosperity.jar
However, double-clicking the .jar file gives the message: "Could not find the main class:", and then gives the path to the .jar file. I've checked a hundred times that the META-INF folder exists inside the .jar file, and that within it there exists a MANIFEST.MF with the correct main class name. I have also checked that the main class (App.class) .class file exists inside the .jar file.
So the question is: what's the difference between double-clicking a file and running javaw on it? It's getting really frustrating that it won't just run!
Thanks for any direction you can give me, I'm tearin' my hair out here!
Perhaps your file associations got messed up. At the command prompt, try running
ftype | find "jarfile"
On my 64-bit Windows 7 computer, that shows
jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*
You can also change it with ftype:
ftype jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*
Just found this post...
If you have the problem only when double clicking the jar file and not at cmd launch, it's probably because the version of the JRE is wrong (6 in place of 7).
Just change the value in regedit at :
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command]
"C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*
to :
"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
There should be no problem if this value is updated.
Note : Switching between 32 and 64 bits versions on Windows :
-> "C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %* will use the 64 bits version of the JRE
-> "C:\Program Files (x86)\Java\jre7\bin\javaw.exe" -jar "%1" %* will use the 32 bits version of the JRE
search your regedit and check follow item
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Applications\javaw.exe\shell\open\command]
#="\"C:\\Program Files (x86)\\Java\\jre6\\bin\\javaw.exe\" -jar \"%1\""
[HKEY_CLASSES_ROOT\jarfile\shell\open\command]
#="\"C:\\Program Files (x86)\\Java\\jre6\\bin\\javaw.exe\" -jar \"%1\""
[HKEY_CURRENT_USER\Software\Classes\Applications\javaw.exe\shell\open\command]
#="\"C:\\Program Files (x86)\\Java\\jre6\\bin\\javaw.exe\" -jar \"%1\""
I came across this error as well. I checked the file association using command prompt and all was correct. It wasn't until I tried running the .jar from the command line using java -jar MyProgram.jar that it actually showed me the root of the problem.
It turns out the .jar was compiled under JDK 7 whereas I was only running JRE 6. This was error given to me in the prompt which lead me to the real solution:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MyProgram/Program : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: MyProgram.Program. Program will ex
it.
I just had the exact same problem, fixed the same way. I had to completely delete the association, not just the user customisation, and reinstall the JRE.
The association before the fix was still:
jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*
And after (the same):
jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*
If the methods above cannot solve the problem, try deleting the .jar file type from your pc (you can google a software called Unassoc.exe and delete the file type), and then the problem is fixed! (At least, this is my case!)