Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How do I run a .JAR file from the terminal?(Ubuntu 12.10 32 bit .JAR file wont execute from command line)
How do I run a .JAR file from the terminal? [message #1016855] Thu, 07 March 2013 22:27 Go to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
MY OS is Ubuntu 12.10 32 bit. I have been exploring a tutorial on writing java applications and I ran into a snag trying to execute a .JAR file from the terminal.


I got a error when I tried to run a java file from the terminal sayiing, "unrecognised option"

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit
So I have this;

http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html


I am now trying to create a manifest.txt file in the .JAR file, which will have the class name

[Updated on: Thu, 07 March 2013 23:45]

Report message to a moderator

Re: How do I run a .JAR file from the terminal? [message #1016860 is a reply to message #1016855] Thu, 07 March 2013 22:58 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 3/7/2013 3:27 PM, Hugh Foster wrote:
> I got a error when I tried to run a java file from the terminal sayiing,
> "unrecognised option"
> Error: Could not create the Java Virtual Machine.
> Error: A fatal exception has occurred. Program will exit

Need a bit more information.

(Don't count on previous threads with different names or a running
conversation with anyone to supply it--I do know you were wanting to
execute your new Java program from the command line, but others may not.)

What OS?
It's not a Java file (.java), but a JAR (.jar) file, right?
What's the command you used to execute it at the command line?
Did you create a "runnable" JAR?
Re: How do I run a .JAR file from the terminal? [message #1016861 is a reply to message #1016860] Thu, 07 March 2013 23:09 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
OS is Ubuntu 12.10. and yes I did create a runnable jar file.... I think I have to crreate an instance of the class and create a manifiest file??
Re: How do I run a .JAR file from the terminal? [message #1016862 is a reply to message #1016861] Thu, 07 March 2013 23:12 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
the command I used was # java -jar jar temp.jar


java /home/lighting/Documents/temp.jar Error: Could not find or load main class .home.lighting.Documents.temp.jar lightning

[Updated on: Thu, 07 March 2013 23:16]

Report message to a moderator

Re: How do I run a .JAR file from the terminal? [message #1016864 is a reply to message #1016861] Thu, 07 March 2013 23:18 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 3/7/2013 4:09 PM, Hugh Foster wrote:
> OS is Ubuntu 12.10. and yes I did create a runnable jar file.... I think
> I have to crreate an instance of the class and create a manifiest file??

But, it's the command line that's troubled, you said.

java -jar project-name.jar

Which option was unrecognised?

As for MANIFEST.MF, I create JARs using ant as my builds must be
reproduceable without Eclipse present. It's been too long since I
created one using Eclipse. I looked for links using "eclipse make
runnable jar". Some were wrong and others moronic. This discussion looks
promising, though:

http://www.coderanch.com/t/556622/vc/Create-Runnable-JAR-File-Eclipse
Re: How do I run a .JAR file from the terminal? [message #1016865 is a reply to message #1016862] Thu, 07 March 2013 23:19 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 3/7/2013 4:12 PM, Hugh Foster wrote:
> the command I used was # java -jar jar temp.jar

That's the problem: remove the second of the three occurrences of "jar"
in that command line.
Re: How do I run a .JAR file from the terminal? [message #1016866 is a reply to message #1016862] Thu, 07 March 2013 23:27 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
and yes sorry for the lack of info. Im working two threads trying to solve this.
Re: How do I run a .JAR file from the terminal? [message #1016867 is a reply to message #1016866] Fri, 08 March 2013 00:07 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
that was my bad too mmany jars was a typo
Re: How do I run a .JAR file from the terminal? [message #1016870 is a reply to message #1016867] Fri, 08 March 2013 00:46 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
lightning@rigel5:~$ java -cp temp.jar.lightning.java.hello.MyFirstClass I typed this in and got a java command usage index and did not display the file.
Re: How do I run a .JAR file from the terminal? [message #1016871 is a reply to message #1016870] Fri, 08 March 2013 00:53 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
Ok, this is my mess...
lightning@rigel5:~$ # java -jar temp.jar
lightning@rigel5:~$
lightning@rigel5:~$ # java -jar temp.jar
lightning@rigel5:~$ # java -MyFirstClass.jar
lightning@rigel5:~$ # java -jar jar temp.jar
lightning@rigel5:~$ java -cp temp.jar.lightning.java.hello.MyFirstClass
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is server,
because you are running on a server-class machine.


-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
lightning@rigel5:~$ java -cp temp.jar MyFirstClass.lightning.java.hello
Error: Could not find or load main class MyFirstClass.lightning.java.hello
lightning@rigel5:~$ java -jar myFirstClass
Error: Unable to access jarfile myFirstClass
Re: How do I run a .JAR file from the terminal? [message #1016875 is a reply to message #1016870] Fri, 08 March 2013 01:19 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 3/7/2013 5:46 PM, Hugh Foster wrote:
> lightning@rigel5:~$ java -cp
> temp.jar.lightning.java.hello.MyFirstClass I typed this in and got a
> java command usage index and did not display the file.

Of course, at this point, you're outside this forum and in the realm of
javaranch.com or stackoverflow.com.
Re: How do I run a .JAR file from the terminal? [message #1017070 is a reply to message #1016875] Fri, 08 March 2013 20:24 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
I thought as much. thanks for the heads up.
Re: How do I run a .JAR file from the terminal? [message #1017135 is a reply to message #1016875] Sat, 09 March 2013 18:52 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
Russell Bateman wrote on Thu, 07 March 2013 20:19
On 3/7/2013 5:46 PM, Hugh Foster wrote:
> lightning@rigel5:~$ java -cp
> temp.jar.lightning.java.hello.MyFirstClass I typed this in and got a
> java command usage index and did not display the file.

Of course, at this point, you're outside this forum and in the realm of
javaranch.com or stackoverflow.com.

Why does Eclipse crash when I select the Javadoc view in the java editor?... For some reason I think all these problems I am having are related to a jre 6 issue... but that is my opinion. I have created a thread at javaranch under a similar name
the execution environment was jre 7 , I have switched it to 6;

the default jre is 7 oracle. that is the only choice in the dialogue.. see screenshot

this is what I think: If I can switch the default to the jre version for this version of juno then it will work, but this is a hunch

[Updated on: Sat, 09 March 2013 19:19]

Report message to a moderator

Re: How do I run a .JAR file from the terminal? [message #1017148 is a reply to message #1017135] Sat, 09 March 2013 21:45 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 03/09/2013 11:52 AM, Hugh Foster wrote:
> HI Gang Im back this time with a fun new riddle: Why does Eclipse crash when I select the Javadoc view in the java editor?... For some reason I think all these problems I am having are reltated to a jre 6 issue... but that is my opion. I have created a thread at javaranch under a similar name
>

Still hijacking threads. Forum etiquette frowns upon that and it's not
helpful to those looking later for the same solutions you're asking about.

The image attached does not (for me) illustrate your question about
"select[ing] the Javadoc view in the java editor".

The Javadoc view is separate from the Java editor. Typically, you ensure
that view is visible in another pane (I keep mine in the upper rightmost
pane with Outline, Search, Ant, etc. When you click in a Javadoc blurb,
it displays it.

Or, are you referring to Content Assist which, when you over over
something that's backed by Javadoc, displays information relevant to the
construction in a pop-up?

If you suspect a JRE issue (Java 6 has been very solid for me), ensure
you're using the very latest version which I show to be update 43. From
Sun, that is. I use openjdk on my servers usually (and it works), but on
my development hosts I only use bonafide Sun JVMs.
Re: How do I run a .JAR file from the terminal? [message #1017178 is a reply to message #1017148] Sun, 10 March 2013 16:26 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
'Still hijacking threads. Forum etiquette frowns upon that and it's not
helpful to those looking later for the same solutions you're asking about.'

I wrote this thread looking for help. Forgive me if my post was inappropriate however I have been polite thus far. Presumably a bug, or confirmations of one is in the interest of your community.

Regardless, I came looking for anwsers and got them; this I like.

I did infact ask you bateman if this issue warranted a standalone thread, so I creeated this. To get reprimanded on it belies more under the surface of your responses that I care to explore.

My problem with the jar file is now solved : I unearthed a semantics error, now that is resolved however the IDE still crashes when i try to access the help libraries and editorial views.

[Updated on: Sun, 10 March 2013 16:29]

Report message to a moderator

Re: How do I run a .JAR file from the terminal? [message #1017179 is a reply to message #1017178] Sun, 10 March 2013 16:50 Go to previous messageGo to next message
Hugh Foster is currently offline Hugh FosterFriend
Messages: 33
Registered: February 2013
Member
as for the java crashes, it goes way beyond my expertise to comment on why in both Pydev and Java perspectives there is a problem with the browser so that it cant render the data.


'The Javadoc view is separate from the Java editor. Typically, you ensure
that view is visible in another pane (I keep mine in the upper rightmost
pane with Outline, Search, Ant, etc. When you click in a Javadoc blurb,
it displays it.'

right . this pane is on the bottom in plain view. I click on it, and same as the library selection in the top right editor... the screens greys and crashes

My java is configured and reconfigured and I have read the documentation on the java now and know that my system is running the correct java. I should also and finally state the error with the javadoc tab and the help library could be a Linux Eclipse conflict that has been mentioned in some forums and it could be an internal java version issue that fortunately have no time to explore.

I was hoping to also grow from this and use this forum as a resource in the future for building community links.. after a name change maybe. have a nice day all and thanks again for the good references
Re: How do I run a .JAR file from the terminal? [message #1017186 is a reply to message #1017179] Sun, 10 March 2013 20:14 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 03/10/2013 10:50 AM, Hugh Foster wrote:
> as for the java crashes, it goes way beyond my expertise to comment on
> why in both Pydev and Java perspectives there is a problem with the
> browser so that it cant render the data.
>
> 'The Javadoc view is separate from the Java editor. Typically, you ensure
> that view is visible in another pane (I keep mine in the upper rightmost
> pane with Outline, Search, Ant, etc. When you click in a Javadoc blurb,
> it displays it.'
>
> right . this pane is on the bottom in plain view. I click on it, and
> same as the library selection in the top right editor... the screens
> greys and crashes
>
> My java is configured and reconfigured and I have read the documentation
> on the java now and know that my system is running the correct java. I
> should also and finally state the error with the javadoc tab and the
> help library could be a Linux Eclipse conflict that has been mentioned
> in some forums and it could be an internal java version issue that
> fortunately have no time to explore.
>
> I was hoping to also grow from this and use this forum as a resource in
> the future for building community links.. after a name change maybe.
> have a nice day all and thanks again for the good references


It wasn't a reprimand, but just an attempt to nudge you to begin a new
thread for each separate issue. If you asked a question that I didn't
respond to, I may not have ready your post attentively enough for which
I apologize.

I haven't done PyDev, so I'm not going to be much help there.

I haven't experienced the crashes you have. My most recent push-back was
an attempt to understand what was giving you trouble exactly.

I'm running Eclipse Indigo, though I have run Galileo, Helios and Juno,
for a very long time on Ubuntu Karmic, Lucid, Maverick and now Precise,
Europa, Galileo and Helios on Windows 7 and openSuSE prior to Ubuntu.
I've experienced none of what I think I understand as your crashes.

If you can muster a stack trace for any of the trouble you experience,
that would be helpful.

I will say that back in the days of Galileo, using Windows 7, I had
troubles crashing while developing for Android until I a) abandoned my
Eclipse Java/JEE for a simple Java one (so, I didn't mix Google ADT in
with Eclipse WTP) and b) ensured I bounced my workbench several times
daily. Since then I don't try to mix types of development on a single
Eclipse installation, but I think it's more superstition on my part than
reality; I've never had any of those troubles on Linux.

Eclipse can sometimes be a pretty steep curve, but that's especially
because it does so much. It also appears weird because fundamentally,
Eclipse is a mass of plug-ins, many developed by sort of "non Eclipse"
people. The support is very heterogeneous too as you're finding out.

I've so far found it worth it, but then I do pretty traditional Java/JEE
development except for some Android once (which, except for the initial
trouble, went very well).
Previous Topic:Eclipse(Juno) is not starting after updating on windows 7
Next Topic:Shortcut for open project tree of current file opened
Goto Forum:
  


Current Time: Fri Mar 29 14:22:10 GMT 2024

Powered by FUDForum. Page generated in 0.07265 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top