LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-04-2014, 09:24 PM   #1
FooIsFood
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Rep: Reputation: Disabled
Getting a jar file to work


Hi,
I am trying to get a jar file to work. My project is a little more complex than this, but, I was able to get the problem to work on a simpler project. Here it is:
[in home/FooIsFood/test directory]
Test.java:
// ==========================================
package test;

public class Test
{
public static void main(String[] args)
{
System.out.println(args[0]);
}
}

Now the manifest Test.mf:

Main-Class: Test

when I build the file like so, it works:
javac Test.java

and run it, this is what I get (as expected)
java Test Hello
Error: Could not find or load main class Test
but, if I change to the directory just below (ala cd ..)
and run:
java test/Test Hello
Hello

works as expected.
When I build the manifest:
(in test directory)
jar cvfm Test.jar Test.mf *.class
added manifest
adding: Test.class(in = 402) (out= 275)(deflated 31%)

I can't run the jar file from anywhere, from the test directory or home/FooIsFood any ideas?
Here's what I get in all cases:
Error: Could not find or load main class Test

Thanks!
 
Old 08-05-2014, 01:40 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,818

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
the normal is this
Code:
cd /to/the/location/of/the/jar
java -jar TheJavaProgram.jar
 
  


Reply

Tags
jar, java


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message "Jar file 'mail.jar' was not found in the extended library directory" AussieAndrew Linux - Newbie 1 07-17-2013 02:40 PM
[SOLVED] Gotta weird file showing up on a .jar file while loading.... EODSteven Linux - Newbie 6 10-03-2012 11:49 AM
How to set mail.jar(JavaMail) and mysql-connector-java.jar in Linux class path Terry56 Linux - Software 3 01-19-2010 10:06 AM
I got error with this command 'java -jar NodeView-v1.1.jar' mohdismiaswaly Linux - Software 3 04-23-2009 07:24 AM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 06:26 AM


All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration