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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.