javac

run a jar file (generated by ant) in command line

喜欢而已 提交于 2019-12-23 02:41:50
问题 I have a build.xml file that works fine. The problem is that the generated jar file, and I need to run it without 'ant run' How can I run the jar file? running with java -jar Main.jar main.Main gives me: Exception in thread "main" java.lang.NoClassDefFoundError: org/neo4j/graphdb/GraphDatabaseService This is how I'm creating the jar file (build.xml): <target name="jar" depends="compile"> <mkdir dir="${jar.dir}"/> <jar destfile= "${jar.dir}/${ant.project.name}.jar" basedir="${build.dir}">

Java: System cannot find the file C:\ … java.exe

被刻印的时光 ゝ 提交于 2019-12-23 01:55:31
问题 I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable. I created a helloworld.java application and am able to compile it using: javac helloworld.java However, when I try to run: java helloworld I get the error: The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe How can I solve this? 回答1: Just set %JAVA_HOME% /bin to your path variable. 回答2: 1.Just go to C:\ProgramData\Oracle\Java\javapath\ 2.You will

java compilation : source, target and release supported versions

倾然丶 夕夏残阳落幕 提交于 2019-12-23 01:15:13
问题 I may do some cross-compilations for legacy projects and I noticed with recent JDKs that we are limited to some specific versions for the source , target and release JVM arguments. How to get the supported versions for these arguments ? 回答1: Indeed the supported values depend on the major JDK version used. You can find the information on the javac documentation of the respective major JDK versions (the links are referenced below). Some general notes about these arguments : The source and the

-sourcepath vs -classpath

女生的网名这么多〃 提交于 2019-12-22 05:54:31
问题 Studying for the oracle certification I am trying all the possible scenarios that might occur during the exam. For example, here there is a little doubt about shell command line (unix based): Let's imagine there is a folder called myProject and a sub folder called myProject/source. File SubFile.java is in the folder myProject/source and another file File.java is in myProject folder. By typing the following commands I get to different behaviors: cd source (therefore, currently I am on

Ant javac task errs out: [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6

元气小坏坏 提交于 2019-12-22 05:53:37
问题 I'm trying to run an ant task that uses axis2-ant-plugin-1.6.0.jar\org\apache\axis2\tool\ant\AntCodegenTask to perform a WSDL2Java operation. At the top of the ant script, I define java6.boot.classpath : <property name="java6.boot.classpath" value="${env.JAVA6_BOOT_CLASSES}"/> And I have the JAVA6_BOOT_CLASSES environment variable set to C:\dev\java\64-bit\jdk-1.6.0_45\bin . The pertinent ant target is as follows: <!-- dist.jar target --> <target name="dist.jar" depends="generate" description

How to make javac compiler write the output to both file and console?

一世执手 提交于 2019-12-22 05:38:31
问题 I am running javac task using ant and I send the output to a log file using -Xstdout compiler argument for reporting purposes, but I would like the output also still being send to the console so hudson can capture it for on screen review. Is there a way for this to be done? 回答1: Just came across another alternative using the recorder task. Nearer as you don't have to introduce new targets. <compile > <record name="log.txt" action="start"/> <javac ... <record name="log.txt" action="stop"/>

Why does javac emit “error: method in class cannot be applied to given types” when an instance method is used in a static context?

你离开我真会死。 提交于 2019-12-22 04:56:18
问题 Consider the following (invalid) Java program: public class Test { public static void main(String[] args) { int[] ints = {1, 2, 3, 4, 5}; print(ints); } public void print(int... ints) { for (int i : ints) { System.out.print(i); } } } I would expect an error similar to this: Cannot make a static reference to the non-static method print(int[]) from the type Test at Test.main(Test.java:5) but instead, javac emits: Test.java:5: error: method print in class Test cannot be applied to given types;

package org.apache.hadoop.conf does not exist after setting classpath

…衆ロ難τιáo~ 提交于 2019-12-22 04:17:19
问题 I am a beginner in hadoop using the hadoop's beginners guide book as a tutorial. I am using a mac osx 10.9.2 and hadoop version 1.2.1 I have set all the appropriate class path, when I call echo $PATH in terminal: Here is the result I get: /Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/oladotunopasina/hadoop-1.2.1/hadoop-core-1.2.1.jar:/Users/oladotunopasina/hadoop-1.2.1/bin:/usr/share/grails/bin:/usr/share/groovy/bin:/Users/oladotunopasina/.rvm/gems/ruby-2.1.1/bin:/Users

Maven: How to specify Javac plugin argument with maven-compiler-plugin?

北城以北 提交于 2019-12-21 06:18:36
问题 Javac provides the following nonstandard option (from "javac -X" command line help): -Xplugin:"name args" Name and optional arguments for a plug-in to be run However, Maven does not handle that format. For example, the following does not work: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArgs> <arg>-Xplugin:"Manifold static"</arg> </compilerArgs> </configuration> </plugin> I've tried several different variations

How can I capture Java compiler errors into a file?

∥☆過路亽.° 提交于 2019-12-21 05:27:11
问题 I compiled a Java program as javac t1.java > a in order to redirect the error messages to file a . But a doesn't have the error contents (they still appear in the terminal). The command is executed from Linux command prompt. The contents of t1.java is as: class t1 { public static void main(String[] args) { System.out.printn("Hello World!"); // Display the string. } } So now there is an error, i.e. println is written as printn . How can I capture this error message in file a ? 回答1: Try