1

(Update below based on comments and answers)


I've developed some Java on Windows, and I've executed it successfully on that machine. For the first time, I'm attempting to execute it on Ubuntu. I installed OpenJDK-7-jre, and have copied the jars and source code over.

The jars:

(djauth_venv)~/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build$ ls -la dependency_jars/
-rw-rw-r-- 1 jeffy jeffy 185140 Jun 12  2012 commons-io-2.4.jar
-rw-rw-r-- 1 jeffy jeffy  18863 Dec 11 12:53 templatefeather-0.1.1.2.jar
-rw-rw-r-- 1 jeffy jeffy 665303 Dec 11 12:52 xbnjava-0.1.5.jar

When attempting to execute it with

java BuildPartFour -classpath /usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar;/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar;/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar;/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar

It results in permission denied for each of the jars:

Exception in thread "main" java.lang.NoClassDefFoundError: com/github/xbn/io/PlainTextFileUtil
        at BuildPartFour.main(BuildPartFour.java:14)
Caused by: java.lang.ClassNotFoundException: com.github.xbn.io.PlainTextFileUtil
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        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)
        ... 1 more
-bash: /home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar: Permission denied
-bash: /home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: Permission denied
-bash: /home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: Permission denied

I've changed the jars to be executable

(djauth_venv)jeffy@originaldjangster:~/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build$ chmod 774 dependency_jars/*.jar
(djauth_venv)jeffy@originaldjangster:~/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build$ ls -la dependency_jars/               total 864
-rwxrwxr-- 1 jeffy jeffy 185140 Jun 12  2012 commons-io-2.4.jar
-rwxrwxr-- 1 jeffy jeffy  18863 Dec 11 12:53 templatefeather-0.1.1.2.jar
-rwxrwxr-- 1 jeffy jeffy 665303 Dec 11 12:52 xbnjava-0.1.5.jar

But now, when attempting to execute it again, I get this crazy output:

Exception in thread "main" java.lang.NoClassDefFoundError: com/github/xbn/io/PlainTextFileUtil
        at BuildPartFour.main(BuildPartFour.java:14)
Caused by: java.lang.ClassNotFoundException: com.github.xbn.io.PlainTextFileUtil
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        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)
        ... 1 more
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar: line 1: $'PK\003\004': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar: line 2: $'v\222\314@': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar: line 21: syntax error near unexpected token `)'
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar: line 21: `▒Ғ▒^w▒ ▒▒W▒!▒▒
N▒
  g▒▒1^▒yKn▒K(▒"▒N▒▒▒
▒F/L*▒vTb6▒▒▒▒l4]▒▒▒hL▒F▒▒▒▒`▒l▒8m▒C▒▒▒▒▒▒▒u▒▒▒A▒*▒O▒▒▒▒6Jys▒▒C%▒▒݅Z▒ب▒&▒@▒▒▒9▒▒▒^▒"▒ID_▒▒▒▒$ +yr.,▒▒趒3▒a▒▒O▒▒▒eq▒▒e▒M▒5|▒Ȓ;▒▒▒=▒<])_▒pڔ▒▒▒D▒▒▒írU$▒E▒+'
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 1: $'PK\003\004': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 2: $'\b\245f\213E': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 3▒f▒E2▒f▒ZgMETA-K-*▒▒ϳR0▒3▒▒r▒Cq,HL▒HU▒%-▒Lx▒▒▒RKRSt▒*A▒▒▒
▒͍t▒
M4▒▒sR▒▒: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 4: $'\362\213\022K\200\3725y\271x\271PK\003\004': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 5:{f▒Ecom/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 6: f▒E com/github/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 6: $'\b': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 7: f▒Ecom/github/aliteralmind/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 7: $'\b': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 8: syntax error near unexpected token `$'com/github/aliteralmind/templatefeather/PK\003\004''
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.2.jar: line 8: |f▒E(com/github/aliteralmind/templatefeather/PK'
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 1: $'PK\003\004': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 2: $'\b\214f\213E': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 3▒f▒E2▒f▒ZgMETA-INF/MANIFEK-*▒▒ϳR0▒3▒▒r▒Cq,HL▒HU▒%-▒Lx▒▒▒RKRSt▒*A▒▒▒
▒͍t▒
M4▒▒sR▒▒: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 4: $'\362\213\022K\200\3725y\271x\271PK\003\004': command not found
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 5:tf▒Ecom/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 6:tf▒E com/github/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 7:zf▒Ecom/github/xbn/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 8:tf▒Ecom/github/xbn/analyze/PK: No such file or directory
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 9: syntax error near unexpected token `$'ʭ\210\342A''
/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar: line 9:tf▒E▒U▒M_-com/github/xbn/analyze/AbstractAnalyzer.class▒▒yS▒@Ɵ▒j!(ʭ▒▒A'
(djauth_venv)jeffy@originaldjangster:~/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build$ PuTTY

Earlier today, I successfully executed this via SFTP on my Windows machine. It's horribly slow, but it works. What do I need to do to execute this directly in Ubuntu?

Thanks.


Updated based on comments and answer

Thank you, @Alex and @ChrisStratton. After making the jars non-executable again and using colons, I'm no longer getting the gibberish, but it still gives me

Exception in thread "main" java.lang.NoClassDefFoundError: com/github/xbn/io/PlainTextFileUtil
at BuildPartFour.main(BuildPartFour.java:14)
Caused by: java.lang.ClassNotFoundException: com.github.xbn.io.PlainTextFileUtil`. 

This class is indeed in the jar:

$7z l /home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)

Listing archive: /home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar


--
Path = /home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.jar

Type = zip
Physical Size = 665303

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2014-12-11 12:52:24 D....            0            0  META-INF
2014-12-11 12:52:22 .....          103           90  META-INF/MANIFEST.MF
2014-12-11 12:51:40 D....            0            0  com
2014-12-11 12:51:40 D....            0            0  com/github
2014-12-11 12:51:52 D....            0            0  com/github/xbn

...

2014-12-11 12:51:40 .....         5523         2651  com/github/xbn/io/IOUtil.class
2014-12-11 12:51:40 .....         2483         1098  com/github/xbn/io/MultiTextAppender.class
2014-12-11 12:51:40 .....         2018          865  com/github/xbn/io/NewPrintWriterToFile.class
2014-12-11 12:51:40 .....         2497          927  com/github/xbn/io/NewTextAppenderFor.class
2014-12-11 12:51:40 .....         1687          685  com/github/xbn/io/NewTextAppenterFor.class
2014-12-11 12:51:40 .....         5655         2311  com/github/xbn/io/PathMustBe.class
2014-12-11 12:51:40 .....         2250          906  com/github/xbn/io/PlainTextFileUtil.class
2014-12-11 12:51:40 .....         1656          871  com/github/xbn/io/PrintStreamForString.class
2014-12-11 12:51:40 .....          458          292  com/github/xbn/io/RTAccessDeniedException.class
2014-12-11 12:51:40 .....          450          288  com/github/xbn/io/RTEndOfFileException.class
2014-12-11 12:51:40 .....          458          288  com/github/xbn/io/RTFileNotFoundException.class

...

------------------- ----- ------------ ------------  ------------------------
                               1437122       545645  621 files, 49 folders

What am I still missing?

aliteralmind
  • 19,847
  • 17
  • 77
  • 108
  • 2
    You don't execute a `.jar` - Java simply needs access. It looks like the class files are corrupted. – Boris the Spider Jan 02 '15 at 15:50
  • 2
    Yes - the semicolons are causing a unix shell to see the jars as distinct commands. On linux use a colon. See http://stackoverflow.com/questions/4528438/classpath-does-not-work-under-linux – Chris Stratton Jan 02 '15 at 15:54
  • possible duplicate of [Classpath does not work under linux](http://stackoverflow.com/questions/4528438/classpath-does-not-work-under-linux) – Chris Stratton Jan 02 '15 at 15:56
  • @ChrisStratton: I've updated the question. Your advice got me a significant step further. – aliteralmind Jan 02 '15 at 16:39
  • There is a backquote after `PlainTextFileUtil` in your last stack trace; question edit error? – fge Jan 02 '15 at 22:00

1 Answers1

5

The jars do not need to be executable

On Windows, the semantics are

java -classpath somejar1.jar;somejar2.jar

But on *NIX, the semantics are

java -classpath somejar1.jar:somejar2.jar

*NIX needs colons (:) not semi-colons (;).

UPDATE

It looks like your command is incorrectly structured, you said you're doing this:

java BuildPartFour -classpath (...)

Where I'm assuming BuildPartFour is a .class file in the current working directory. This would result in running your BuildPartFour class passing in -classpath (...) as arguments to your program (these would be visible in the public static void main(String[] args) args array

It should be this:

java -classpath (...) BuildPartFour

The general java command structure is:

java [options] [class] [args]
Alex
  • 2,435
  • 17
  • 18
  • I've updated the question. This has gotten me a significant step further. – aliteralmind Jan 02 '15 at 16:39
  • Yes, this. Currently `-classpath` is being passed as an argument to the application, **not** the JVM. – Boris the Spider Jan 02 '15 at 21:45
  • That's it. I've forgotten the basics. Actually, it was necessary to add a "." to the classpath, in order to find the class-to-be-executed itself. – aliteralmind Jan 04 '15 at 16:43
  • Final command is `java -classpath .:/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/xbnjava-0.1.5.1.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar:/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/commons-io-2.4.jar:/home/jeffy/django_files/django_auth_lifecycle/non_django_files/wordpress_posts/build/dependency_jars/templatefeather-0.1.1.3.jar BuildPartFour` – aliteralmind Jan 04 '15 at 16:43