javac

Java: How can I compile an entire directory structure of code ?

浪子不回头ぞ 提交于 2019-12-17 02:35:14
问题 The use case is simple. I got the source files that were created using Eclipse. So, there is a deep directory structure, where any Java class could be referring to another Java class in the same, child, sibling or parent folder. How do I compile this whole thing from the terminal using javac ? 回答1: You have to know all the directories, or be able to use wildcard .. javac dir1/*.java dir2/*.java dir3/dir4/*.java dir3/dir5/*.java dir6/*src/*.java 回答2: With Bash 4, you can just enable globstar

Creating a batch file, for simple javac and java command execution

孤人 提交于 2019-12-14 00:19:37
问题 It is a really simple thing but I cannot get my head around it. I have looked at plenty of StackOverFlow post and as well as on internet. My goal is to create a .bat which will open cmd and execute my Main.java into command prompt. Easy isn't it, but I have got confused about how? Below I am writing steps which my batch file should perform open cmd javac Main.java java Main My file will reside next to all my .java so I am assuming I don't need to give explicit path. My understanding so far by

Javac erroring out when compiling Servlet libraries

我怕爱的太早我们不能终老 提交于 2019-12-13 19:46:59
问题 I am using ubuntu and I have set my paths to be the following: JAVA_HOME=/usr/local/jdk1.6.0_24 export CLASSPATH=/usr/local/tomcat/lib export JAVA_HOME I thought that would put the servlet libraries in the compile path, but I am still getting compile errors like this: package javax.servlet does not exist [javac] import javax.servlet.ServletException; Any ideas how to fix this or what I am doing wrong? The general Java libraries seem to be working fine. 回答1: With jar files, simply specifying a

Gradle: How to compile Java by eclipse ECJ (JDT core) by running Gradle 4.1 task

ぐ巨炮叔叔 提交于 2019-12-13 17:50:23
问题 I have a project that can be build well by eclipse (ECJ) But Oracle javac can't build it (some reasons like in link: the different of ecj and javac). I would like moving from eclipse to build by Gradle, in order to Jenkins can run Gradle script. But Gradle always use javac to compile. I used the plugins 'eclipse, eclipse-wtp' or library, dependency of jdt to config gradle use ECJ like that but it still don't use ECJ to compile: compileJava{ options.forkOptions.with { executable = 'java'

Java programmatically compile jar

≡放荡痞女 提交于 2019-12-13 14:36:23
问题 I have java source code in a text file. There has to be entered some custom hard coded variables into the source code and then it has to be turned into a jar. This works but when I run the jar, the Main class can not be found. When I extract the jar file with WinRAR, I can't seem to find an error. When I run the generated/extracted class file via cmd, I get "Error: Could not find or load main class Main" generated manifest: Manifest-Version: 1.0 Main-Class: javabinder.Main Source code: public

compile files from different directories with javac, referring a depending jar file?

余生长醉 提交于 2019-12-13 08:06:01
问题 I have the following set up: I have 4 packages: root/src/terminal - has some java files root/src/mail - has some java files root/src/data - has some java files root/src/main - has a single java file, Main.java I also have the following files root/bin - a folder to store .class files root/mail.jar - a jar file which has important classes used in my code Within the root, I would like to enter a terminal command which compiles root/src/main/Main.java and puts the class files in the root/bin

Compile a java file using docker with own path

走远了吗. 提交于 2019-12-13 05:42:34
问题 Hy. I'm trying to compile a .java file using docker. I read the files on docker's website, also I read these links: docker's website about volumes and another question I had put up for gcc compiler I understood the concept for the gcc compiler since it doesn't create any extra file for compiling. But the java one does. It creates a Main.class file on my /home directory if I use the following command and compile a file named Main.java sudo docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src

apache commons: ClassNotFoundException

你。 提交于 2019-12-13 05:18:27
问题 I'm trying to benefite from the EnumeratedIntegerDistribution() from org.apache.commons.math3.distribution , as shown below. I'm working wiht jdk7 , on windows Xp, running from Command Line, in one and only project folder I do: download commons-math3-3.2 and unpackage it to my folder, where my java is. compile my source with (no errors no warnings) javac -cp commons-math3-3.2/commons-math3-3.2.jar CheckMe.java run java CheckMe Here is the demonstration: import java.lang.Math.*; import org

Command works in interactive shell but not shell script

拈花ヽ惹草 提交于 2019-12-13 04:28:19
问题 I wrote a script that would generate the appropriate arguments to javac to compile my project in an effort to grow more proficient at shell scripting. The weird this is.. The script works perfectly, but if the script runs javac with those parameters it doesn't work, and if I run the exact same command in the interactive shell it does. Everything is outputted with absolute paths, so I'm pretty much at a loss here. Example directory structure: src/File.java src/File.png src/dir/File2.java jars

Java: EnumSet.copyOf — is there a room for improvement?

*爱你&永不变心* 提交于 2019-12-13 00:04:07
问题 I need to create an EnumSet from a Set. I decided to use the EnumSet#copyOf method. However, because of a restriction on this method: the specified collection must contain at least one element (in order to determine the new enum set's element type) I need to ensure that the collection is not empty. The code then becomes: enum Color {RED, GREEN, BLUE}; Set<Color> set = ... // get it from somewhere if (set.isEmpty()) { return EnumSet.noneOf(Color.class); else return EnumSet.copyOf(set); Perhaps