I'm running Ubuntu and want to execute a Java file from terminal by including multiple jar files.   All my jars are included in tha jar folder.  I tried  javac -cp jar/A.jar: jar/B.jar: jar/C.jar: jar/D.jar MyFile.java   I get below error.  javac: invalid flag: jar/B.jar: Usage: javac &lt;options&gt; &lt;source files&gt; use -help for a list of possible option   Can anyone guide how to use multiple jars in classpath ?
21548
Is there a way to include all the jar files within a directory in the classpath?  I'm trying java -classpath lib/*.jar:. my.package.Program and it is not able to find class files that are certainly in those jars.  Do I need to add each jar file to the classpath separately?
3529
I have a systemd file to start a jar file. But I want to execute jar file as *.jar. Is there a way to do this?   [Unit] Description=Test Background  [Service] ExecStart=/usr/bin/java -jar /var/www/test.com/*.jar Type=simple WorkingDirectory=/var/www/test.com  [Install] WantedBy=multi-user.target   I tried this but not working.
123877
I'm writing a java app using eclipse which references a few external jars and requires some config files to be user accessable.   What is the best way to package it up for deployment? My understanding is that you cant put Jars inside another jar file, is this correct? Can I keep my config files out of the jars and still reference them in the code? Or should the path to the config file be a command line argument? Are there any third party plugins for eclipse to help make this easier? I'm using an ant build file at the moment but I'm not sure I know what I'm doing. Is there an equivelent of the deployment projects in Visual studio, that will figure out everything you need and just make an installer? I've used install4j before, and it was powerful if no where near as automated as  .Net deployment projects.   Cheers.
81239
I'm a C++ developer - not a java developer, but have to get this code working...  I have 2 public classes that will be used by another product.  I used the package directive in each of the java files.    package com.company.thing;  class MyClass ...   When I try to compile a test app that uses that I add   import com.company.thing.*;   The javac compiler fails with errors about com.company does not exist.  (even if I compile it in the same directory as the class files I just made a package of)  I am sure I am doing something bone-headed and silly.  I've read the  pages and tried to set up a directory structure like /com/company/thing  etc, but either I have totally screwed it all up or am missing something else.  EDIT thanks for the suggestions - I had tried the classpath previously.  It does not help.  I tried compiling   javac -classpath &lt;parent&gt; client.java    and the result is:  package com.company does not exist   I have the code I want to import (the two java files) in \com\company\product.  I compile those fine.  (they contain MyClass) I even made a jar file for them.  I copied the jar file up to the parent directory.  I then did (in the parent directory with the client java file)   javac -cp &lt;jarfile&gt; *.java   the result is:  cannot access MyClass bad class file: MyClass.class(:MyClass.class) class file contains wrong class: com.company.product.MyClass Please remove or make sure it appears in the correct subdirectory of the classpath.   EDIT  I got the client code to compile and run if I used the fully qualified name for MyClass and compiled it in the parent directory.  I am totally confused now.    compiled with no classpath set - just   javac *.java    in the parent directory - and it worked fine.  I can get a test app to compile, but that is not going to cut it when i have to integrate it into the production code.  Still looking for help.  EDIT:  Finally - not sure why it didn't work before - but I cleaned up all the files all over the directory structure and now it works.    Thanks
43021
I am executing an exe through my java program. The path is hardcoded in Java.  I have packaged my the exe in the jar.  But am stuck as I have the path name hardcoded in the Java file, so I am not able to execute my jar as a stand alone program.  Any hints for packaging such jar i.e having an exe inside and able to run it as a stand alone program?
14438
Why is it so hard to do this in Java? If you want to have any kind of module system you need to be able to load JAR files dynamically. I'm told there's a way of doing it by writing your own ClassLoader, but that's a lot of work for something that should (in my mind at least) be as easy as calling a method with a JAR file as its argument.  Any suggestions for simple code that does this?
43440
java program is not running on my windows 10 pc.  C:\Users\Antony&gt;set path=C:\Program Files (x86)\Java\jre1.8.0_171\bin  C:\Users\Antony&gt;cd Desktop  C:\Users\Antony\Desktop&gt;javac helloworld.java 'javac' is not recognized as an internal or external command, operable program or batch file.  C:\Users\Antony\Desktop&gt;  environment path =C:\Program Files (x86)\Java\jre1.8.0_171\bin   C:\Users\  java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode, sharing)   still showing same error
109794
I have a problem running .jar files by double-clicking them. When I go to the Properties dialogue I can't find Java--only Archive Manager in the list of programs. But java -jar somefile.jar opens the program.
113814
My project is to develop an installer which is an executable for Windows, Mac and Ubuntu. The executables on Windows, Mac and Ubuntu are .exe, .app and .deb respectively. So, I converted my .jar file to a .exe file on Windows using a software called launch4j. And on MAC I used a software called Jar-Bundler to convert my jar in to .app file. I want to know if there is any specific software on Ubuntu to convert my jar file in to a .deb file.
81570
I have installed Ubuntu 12.04 LTS server .  How can i run more than .sh file in the same time  (opening more than terminal)  I can use it on desktop version but i use server version.  Is it possible? if yes how can do?
107809
I'm an entry level programmer so please be descriptive in your responses.  I am trying to use a Java API given as a .jar file in my C# .net application.  I don't know much Java, but this .jar file says "no main-class manifest attribute" when I try to run it so this means its a library?  This Java API also comes with a .java file which shows how to use the library but I cannot see the code inside the .jar.  I found  on this site, and one of the answers reads, "In simple way you can pack your java classes to jar file then In C# use Process class for execute and map IO stream."  I am semi-familiar with the Process class in C# but I don't understand how I could use it to use a Java library in my C# .net project.  Is this possible? or was that answer incorrect?  If so, could you explain how I can use the .jar library in my C# app.
41843
Problem  I have an Ubuntu 11.04 Virtual Machine and I wanted to set up my Java development environment. I did as follows   sudo apt-get install openjdk-6-jdk Added the following entries to ~/.bash_profile  export JAVA_HOME=/usr/lib/jvm/java-6-openjdk  export PATH=$PATH:$JAVA_HOME/bin  Save the changes and exit Open up a terminal again and typed the following  echo $JAVA_HOME   (blank) echo $PATH        (displayed, but not the JAVA_HOME value)  Nothing happened, like if the export of JAVA_HOME and it's addition to the PATH were never done.   Solution  I had to go to ~/.bashrc and add the following entry towards the end of file  #Source bash_profile to set JAVA_HOME and add it to the PATH because for some reason is not being picked up . ~/.bash_profile   Questions   Why did I have to do that? I thought bash_profile, bash_login or profile in absence of those two get executed first before bashrc.  Was in this case my terminal a non-login shell? If so, why when doing su after the terminal and putting the password it did not execute profile where I had also set the exports mentioned above?
107891
I'm running an Ubuntu 14.04 and want to install the Eclipse IDE for both Java and C/C++ programming. I installed the separate installation files from their official website. I followed this thread . (The top answer)   The steps helped me install the Java IDE but I don't know what changes I should make to the procedure to install the C/C++ IDE.   Another thread , recommended to install eclipse-cdt but the Eclipse version installed is outdated. (Doesn't allow me to install Pydev)   I have TWO questions:   Can the C/C++ libraries be downloaded from within eclipse, like Pydev? If not, how do I install both IDEs without interfering with each other?   P.S. I commented this query in the first thread but got no reply, that is why I'm asking a fresh question!
19207
So my 2009 new years resolution is to learn Java.  I recently acquired "Java for Dummies" and have been following along with the demo code in the book by re-writing it using Eclipse.  Anyway, every example in the book that uses a relative path does not seem to read the .txt file it's supposed to read from.  Here is the sample code:  import java.util.Scanner; import java.io.File; import java.io.IOException; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.GridLayout;  class TeamFrame extends JFrame {      public TeamFrame() throws IOException {         PlayerPlus player;         Scanner myScanner = new Scanner(new File("Hankees.txt"));          for (int num = 1; num &lt;= 9; num++) {             player = new PlayerPlus(myScanner.nextLine(), myScanner.nextDouble());             myScanner.nextLine();             addPlayerInfo(player);         }                add(new JLabel());         add(new JLabel("   ------"));         add(new JLabel("Team Batting Aberage:"));         add(new JLabel(PlayerPlus.findTeamAverageString()));         setTitle("The Hankees");         setLayout(new GridLayout(11,2));         setDefaultCloseOperation(EXIT_ON_CLOSE);         pack();         setVisible(true);     }      void addPlayerInfo(PlayerPlus player) {         add(new JLabel(player.getName()));         add(new JLabel(player.getAverageString()));     } }   And you can see in the below screen shot I have included this file.  image no longer available  Also, I have verified that when I build the application that a copy of Hankees.txt is placed in the bin folder with the compiled .class files.  Lastly, if I change line 12 to the following and place Hankees.txt in the root of my C:\ drive the program compiles and runs fine.  Scanner myScanner = new Scanner(new File("C:\\Hankees.txt"));   So basically, my question is what am I doing wrong?  Or is Eclipse responsible for this in some way?  Thanks for any and all help!
29570
I was curious how I would go about running multiple commands via shell script.  For example, just to try it out, I'd like to be able to connect a .desktop to a .sh that will run all the update codes so I don't have to type it out. I know how to execute a single command via a .sh, not multiple.  Any way?
95851
I have made a Java program that could open any application. Suppose there is a file name "*.jpg", the it would allow the OS to recognize the type of application and then open the default application. Another example: Suppose the file's name is "*.flv", then it would open up the default media player just like when you click an icon in nautilus but the only difference was that it was in command line. Here is the java program for that:  import java.awt.*; import java.io.*; public class OpenFile{     public static void main(String args[]){       try{           String filename = args[0];           System.out.println(args[0]);           Desktop.getDesktop().open(new File(filename));       }       catch(Exception e){           System.out.println("Sorry an exception occured. Could not perform the operation.");       }     }  }   Now this script leads to performance issues. Now I want to write a BASH script to do this task ??
22283
Before I add more detail to my question, I have to say something very important: Yes, my script has &quot;Allow executing file as program&quot; turned on. The question itself: For programming reasons (shared libraries), I can't execute my program just from the executable, because I need to access LD_LIBRARY_PATH before executing the program. I created this script to do this (baring in mind this is my first time ever writing a script): #!/bin/bash #Get the current directory and append the SO's location currentDir=$(pwd)'/libs/'  #Change the library path export LD_LIBRARY_PATH=$currentDir  #Run the program ./program  After running this from the terminal I thought that it has worked, there were no errors and the program didn't complain about shared libraries. But unfortunately, if I try to double-click the .sh file from Nautilus, nothing happens. The worst part as well, is that since I'm running it from the GUI, I have no idea what error it is getting. I'm running Ubuntu 14.04 and the executable is a C++ program using the SFML libraries (Yes I could just have the dependencies, but SFML isn't commonly installed on Linux computers, and this is besides the point).