Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
My employer has given me access to a site that teaches many things (not sure if allowed to post the name or not). I have decided to try and learn Java. The way this site teaches it is through IntelliJ, but I have learned JavaScript, Python, Node, and React in VSCode, and I don't want to learn another system.
Through Google, I downloaded JDK 11, as well as the Java Extension Pack. I have had a few errors that I have been able to resolve, but I am now stuck on java App.java. Earlier in the day, I was able to make it work, but now when I try to run javac App.java and then java com.example.App, it's not found. Nothing I have tried has made it work. Maybe it only worked before I used Maven...can't remember.
On the topic of com.example.App, is there an easy way to create a package? Google says it's almost always needed to create a package. Only way I've figured out how to do that is with Maven, but the quickstart version is 1.7 or 8 (when I have 11). So I have to go into the POM and edit
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
to
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Is there a way to create a package without using Maven?
I just realized that I haven't even explained my title. So on the site I'm learning Java, it says there's a way to use command line arguments, for example:
java com.example.App "I am an argument"
Since I can no longer run my code with java, I can not do that. If anyone can help, you'd be amazing!
Q: Is there a way to create a package without using Maven?
I don’t see any direct relation between the two.
Packages are the logical grouping of classes in a folder structure in Java whereas Maven is just a Java build tool.
Yes, you can create packages without using Maven.
If you are using any IDE, for example VS Code you can always create packages as below:
Create a Maven based Java project. Maven projects have the following structure
src/main/java (all your source code goes here) and src/main/test (unit test goes here) , src/main/resources(non java files goes here).
Initially while creating the project you would have created a package with name com.example
To create a new package, right click and select New folder
Enter the folder name(this is your package name),for example "view".
Now you will have a new package com.example.vew. Similarly we can create packages at any folder level and place our Java file inside that.
Let me know if you this is good enough for you.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 months ago.
Improve this question
I am trying to build the sample javaFX application in the Intellij 2018.3 IDE. I have installed the oracle JDK11, and downloaded openjfk11. I created a library linked to the javafx sdk and added the line --module-path=${PATH_TO_FX} --add-modules=javafx.controls,javafx.fxml to the VM options line. PATH_TO_FX is defined as an environment variable pointing to my javaFX folder.
I have searched through a number of postings on this site, including This solution to my exact error message. The odd thing I cannot figure out is, This solution works for me if there is no build directory. But if I have already built the project once, it then refuses to run and gives me the stated error. If I delete the build directory and try again, then the program runs correctly again.
Well It looks like I just goofed up something with the output directory because this morning I tried resetting the build path to the default and it just started working.
Try adding path to JavaFX SDK lib folder instead of just the JavaFX SDK.
It worked for me.
ex:
--module-path C:\javaFX\javafx-sdk-11.0.2\lib --add-modules javafx.controls,javafx.fxml
*Replace the "C:\javaFX\javafx-sdk-11.0.2\lib" part with the path to your javaFX SDK "lib" folder.
You should not use VM Path if you define exports and opens in module-info.java. Because VM Path is essential if do not explicitly define module. Then IntelliJ internally creates a module for us.
if you use IntelliJ , you must delete module-info.java in src/main/java, i did and it works,
this file is automatically generated when you create javafx project
Confirm if you didnt add the javafx sdk to the class path instead of the modulepath
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am currently 3 months+ into programming and am trying to build an android app that takes data from Quandl.
How do I import the Quandl library into my Android project? I have tried to search for answers - they typically tell me to add the .jar file, but there is no .jar file in the Quandl library here (taken from the link below).
https://github.com/jimmoores/quandl4j
Will really appreciate it if someone posts a step by step guide for a noob beginner like me.
The answer is in the link you have provided:
https://github.com/jimmoores/quandl4j.
Look at Quick Start section. You have four options.
You can download zip. There is source code inside. You should unzip this archive and then use maven to build jar file. Go to main directory, where pom.xml file is and execute mvn install. If build is successful then jar file should be in target directory.
If you are familiar with git you can clone repository and as previous crate jar with maven (mvn install).
You can use maven to add dependency to your project automatically.
You can use gradle, another tool that automates process of building dependency.
Generally speaking: you are new to programming, spend some time learning about maven, because this tool will help you a lot in your career.
https://maven.apache.org/
After reading this answer please remove this question, because it has a little value for community.
This question already has an answer here:
Create a project from existing source code?
(1 answer)
Closed 7 years ago.
I downloaded an open source Java library that is distributed as source code (Apache Crunch). I want to include it in my Intellij Idea project, as source code, and have the classes available to my code (including auto-completion etc).
Is this possible? Or do I have to compile the library to JAR first?
I think auto-completion works with java's reflection API (at least for eclipse). The IDE need to have the class compiled and loaded in his classpath to be able to use reflection method on the class.
Maybe this post can help
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I've been using the Eclipse references (Ctrl+shift+G) for sometime now. I notice that Eclipse misses finding some references sometimes. Is there something I must configure to get this working correctly?
Your problem may be related to issues concerning Eclipse's CODAN indexer. Try to rebuild the index by clicking [Project Explorer] > Index > Rebuild. Goto Eclipse > Preferences > C/C++ > Indexer and check if your indexer is setup correctly...
I just sorted out a similar-sounding problem.
In my case I was mistakenly ending up with a project->JAR dependency rather than a project->project dependency.
This involved a specialized import of a set of Java-based projects, with logic to
set up a project->project dependency if possible and a project->JAR dependency if
the source was unavailable.
(This wasn't using Maven but from what I know of Maven<->Eclipse integration I could
imagine this happening in a similar case).
So typically I get a project->project dependency but I had messed something up in my filesystem so I ended up with a project->JAR dependency without realizing it...and Ctrl+Shift+G stopped working.
This happened to me working with a Java/Maven project just recently as well. The version of Eclipse was Neon.3 Release (4.6.3).
Rebuilding the projects using Project -> Clean... did not help. The solution was to close and then reopen the projects. After that, the call hierarchy was correctly calculated again.
There's a long standing open bug for this issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=108749
In my case I have imported two maven projects to eclipse. One was depending on another and references in dependent project were not found. I have right clicked on dependent project choose preferences->java build path then removed dependency from Libraries tab and added same dependency to projects path. Of course I had to have both projects in workspace.
Ensure that your project is of the type expected. My similar symptom turned out to be because the eclipse project had been recently re-imported as a general project. Once I realized that and converted it to a C/C++ project, find references again worked as expected.
I'm just starting with Android developmenent using Eclipe and have already run into some basic questions. I have some beginning books such as "busy coders guide to Android..." and "Teach Yourself Android Application Dev't in 24 Hours", however, I'm not seeing some basic things covered.
Can someone tell me how to set up a library and then use it in a project? I have some example code where they have a folder appearing in Ecliple called, "DataGatherLib" Right clicking and hitting properties reveals it is of type "Linked Folder". I suspect this is what I want. So my specific questions are:
1. How do you set up your own library project (Linked Folder if that's appropriate) in Eclipse.
How then, do you use your newly created library in a Ecliple Android Project?
More generally, can someone point me to some good beginner references (books or online tutorials) that cover this. I would think that organizing your code in libaries as opposed to one big application is fairly basic, but I can't seem to find the discussion.
Thanks,
Dave
In Eclipse right-click on your project, select "Properties", then "Android" and you see a page to add a library project.
BTW, you should do the same on the library project and mark it as a library first before you can add.
Alternatively you can drag and drop jars to your project and add them to your classpath, but in this case you can only access class files and not the resource files in the jar.